コインルールスクリプトに基づくOBVピラミッド戦略

作者: リン・ハーンチャオチャン, 日時: 2023-12-08 15:58:29
タグ:

img

概要

この戦略は"OBVピラミッド"と呼ばれる.OBV指標に基づいてポジション開設を設計し,Pyramidの上昇ポジションアプローチを採用して,トレンドが現れた後に利益を追跡する.

原則

この戦略は,トレンド方向を決定するためにOBV指標を使用する.OBV指標は,取引量の変化に基づいて価格動向を判断する.取引量の変化が市場参加者の態度を反映しているため.OBV線が0を超えると,購買力が強化され,上昇傾向が形成されることを示唆する.0を下回ると,販売圧力の強化と下落傾向を示唆する.

この戦略は,OBVが0を超えると上昇傾向が確認される.上昇傾向が形成されると,ピラミッド上昇ポジションルールは設定され,最大7回の追加購入を可能にします.利益とストップ損失を設定しながらトレンドから利益を得ることを目指します.

利点分析

この戦略の最大の利点は,トレンドを追跡し,そこから利益を得るためにピラミッドアプローチを使用してトレンドを捕捉することです.また,利益とストップ損失の設定で堅牢なリスク制御があります.

具体的には,主な利点は以下の通りです.

  1. OBV を使って正確な傾向判断
  2. 利益を追跡するためのピラミッド型買い物
  3. 利益/ストップ損失をコントロールするリスク
  4. シンプルで明確な論理です

リスク分析

主なリスクは2つの側面から生じる.

  1. 誤った OBV 信号により機会が逃れられ,誤った入力が行われる.
  2. 余分な買い物がリスクを増大させる

解決策:

  1. OBV パラメータを最適化して正確性を確保する.
  2. 制御可能なリスクのために追加購入を合理的に制限する.

オプティマイゼーションの方向性

主な最適化方向:

  1. OBVパラメータの最適化により,より高い精度を得る.
  2. 追加購入数と金額の最適化
  3. 利益/ストップ損失の最適化
  4. 他の指標を組み込み,OBVのみに依存しないようにする.

戦略をより安定し,制御し,拡張可能にする.

結論

基本的には,これは非常に実践的な戦略である.トレンド方向を決定するためにOBVを使用し,その後,利益のトレンドにピラミッドを設定する.論理は簡単でバックテストのためのシンプルで明確である.適用価値があり,さらなるパラメータ,リスクおよびマネーマネジメントの最適化により,パフォーマンスはさらに向上し,追加の研究を保証することができます.


/*backtest
start: 2023-11-07 00:00:00
end: 2023-12-07 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RafaelZioni

//@version=4

strategy(title = " OBV Pyr", overlay = true, pyramiding=5,initial_capital = 10000, default_qty_type= strategy.percent_of_equity, default_qty_value = 20, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.075)
strat_dir_input = input(title="Strategy Direction", defval="long", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)

//
fastLength = input(250, title="Fast filter length ", minval=1)
slowLength = input(500,title="Slow filter length",  minval=1)
source=close
v1=ema(source,fastLength)
v2=ema(source,slowLength)
 
//
 
filter=true 
src = close


LengthOBV = input(20)

nv = change(src) > 0 ? volume : change(src) < 0 ? -volume : 0*volume 
c = cum(nv) 
c_tb = c - sma(c,LengthOBV) 

// Conditions

longCond = crossover(c_tb,0)
//shortCond =crossunder(cnv_tb,0)

//

longsignal  = (v1 > v2 or filter == false ) and longCond
//shortsignal = (v1 < v2 or filter == false ) and shortCond 
 
//set take profit
 
ProfitTarget_Percent = input(3)
Profit_Ticks = close * (ProfitTarget_Percent / 100) / syminfo.mintick
 
//set take profit
 
LossTarget_Percent = input(10)
Loss_Ticks = close * (LossTarget_Percent / 100) / syminfo.mintick
 
 
////Order Placing
//
strategy.entry("Entry 1", strategy.long, when=strategy.opentrades == 0 and longsignal)
//
strategy.entry("Entry 2", strategy.long, when=strategy.opentrades == 1 and longsignal)
//
strategy.entry("Entry 3", strategy.long, when=strategy.opentrades == 2 and longsignal)
//
strategy.entry("Entry 4", strategy.long, when=strategy.opentrades == 3 and longsignal)
//
strategy.entry("Entry 5", strategy.long, when=strategy.opentrades == 4 and longsignal)
//
strategy.entry("Entry 6", strategy.long, when=strategy.opentrades == 5 and longsignal)
//
strategy.entry("Entry 7", strategy.long, when=strategy.opentrades == 6 and longsignal)
//
//
//
if strategy.position_size > 0
    strategy.exit(id="Exit 1", from_entry="Entry 1", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 2", from_entry="Entry 2", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 3", from_entry="Entry 3", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 4", from_entry="Entry 4", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 5", from_entry="Entry 5", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 6", from_entry="Entry 6", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 7", from_entry="Entry 7", profit=Profit_Ticks, loss=Loss_Ticks)
    


もっと