アダプティブATRトレンドブレイク戦略

作者: リン・ハーンチャオチャン, 日付: 2023-10-31 15:58:46
タグ:

img

概要

この戦略は,ATR指標に基づいたトレンドブレイク戦略である.その主なアイデアは,価格がATRの一定倍数を超えるとトレンドブレイクトレードを行うことである.この戦略には,トレンド確認と日付範囲内のトレードを制限することも含まれる.

原則

この戦略は,価格変動を測定するためにATR指標を使用する.ATRは平均の真の範囲を表し,期間中の平均変動を測定する.戦略の長さパラメータはATR期間を計算し,numATRsはブレイクアウトのためのATR倍数を表します.

価格がATRの上位numATR倍数を超えると,ロングポジションがとられる.価格がATRの下位numATR倍数を超えると,ショートポジションがとられる.

さらに,この戦略は,長い取引または短い取引のみを制御するために,NeedlongとNeedshort bool変数を含みます.また,指定された日付内の取引を制限するために日付範囲を設定します.

この戦略は,ポジションのサイズを決定するためにサイズ変数を使用し,口座資本の割合に基づいてオーダーのサイズを計算します.

利点

  • ATR を使って,手動の利益/損失設定なしで市場変動に自動的に適応します.

  • ロング,ショート,ロング/ショートのみを選択できます.

  • 重要なイベントで取引を避けるために日付範囲を設定できます.

  • フレキシブルなポジションのサイズ設定は,口座の自己資本の割合に基づいて行われます.

リスク と 解決策

  • ATRは価格変動のみを考慮します. 巨大な市場変動の間には十分なストップロスはありません. 他の指標を組み合わせることもできます.

  • 日付範囲の制限は,前後の適切な設定がない場合,機会を逃す可能性があります. 日付範囲をわずかに拡大することができます.

  • 株価の割合を小さくすると 単一の取引で大きな損失を伴う.合理的な割合が必要.

最適化 の アイデア

  • トレンドフィルターに移動平均値を追加し,誤ったブレイクノイズ取引を減らす.

  • 最適なパラメータを見つけるために ATR 期間をテストする.

  • 他の戦略と組み合わせて 強みを活用し 安定性を向上させる

結論

これは,波動性に対応するためにATRを使用する戦略に従う理解できる傾向である.パラメータの最適化および他の戦略との組み合わせは,パフォーマンスと安定性をさらに向上させることができる.しかし,大きなシングルトレード損失を避けるべきであり,巨大な変動の間に不十分なストップを注意しなければならない.


/*backtest
start: 2023-09-30 00:00:00
end: 2023-10-30 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=3
strategy(title = "Noro's Volty Strategy v1.0", shorttitle = "Volty 1.0", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 100)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(false, defval = false, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Lot, %")
length = input(5)
numATRs = input(0.75)
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//Indicator
atrs = sma(tr, length) * numATRs

//Trading
size = strategy.position_size
lot = 0.0
lot := size == 0 ? strategy.equity / close * capital / 100 : lot[1]
if (not na(close[length])) and needlong
    strategy.entry("L", strategy.long, lot, stop = close + atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if (not na(close[length])) and needlong == false
    strategy.entry("L", strategy.long, 0, stop = close + atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if (not na(close[length])) and needshort
    strategy.entry("S", strategy.short, lot, stop = close - atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if (not na(close[length])) and needshort == false
    strategy.entry("S", strategy.short, 0, stop = close - atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

もっと