
この戦略は,移動平均と価格突破の概念を組み合わせたトレンドライン突破に基づく取引システムである.戦略の中心は,閉盘価格が移動平均の突破を監視することによって取引信号を生成し,近年の低点と2:1の比率のストップをベースにリスクを管理する.戦略は,シンプルな移動平均をトレンド指標として使用し,価格と均線の交差によってトレンドの方向の変化を判断する.
戦略は20周期のSMAをトレンド指標として使用する.閉盘価格が平均線の下から突破して上を突破すると,システムは複数の信号を生成する.ストップは過去7K線の最低点に設定され,入場点にあまりにも近い状態を避ける.ストップポジションの設定は,ストップ距離の2倍であるクラシックな2:1の損失を採用している.戦略には,トレンドライン,取引信号,およびストップポジションをグラフに注記するビジュアル構成要素も含まれている.
これは,構造が整い,論理が明確でトレンドフォロー戦略である.移動平均を突破してシグナルを生成し,合理的なリスク管理メカニズムと連携し,良い実用性がある.いくつかの固有のリスクがあるが,推奨された最適化方向によって,戦略の安定性と収益性をさらに向上させることができる.戦略は,トレンドが顕著な市場環境で使用し,トレーダーは,特定の市場の特徴に応じてパラメータ設定を調整することができる.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-11 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Trend Breakout with SL and TP", overlay=true)
// Parametrlar
length = input(25, title="Length for SL Calculation")
trendLength = input(20, title="Trend Line Length")
// Trend chizig'ini hisoblash
trendLine = ta.sma(close, trendLength)
// Yopilish narxi trend chizig'ini yorib o'tganda signal
longSignal = close > trendLine and close[1] <= trendLine
// Oxirgi 7 shamning minimumini hisoblash
lowestLow = ta.lowest(low, 7)
// Stop Loss darajasini belgilash
longSL = lowestLow // SL oxirgi 7 shamning minimumiga teng
// Take Profit darajasini SL ga nisbatan 2 baravar ko'p qilib belgilash
longTP = longSL + (close - longSL) * 2 // TP 2:1 nisbatida
// Savdo bajarish
if longSignal
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit", "Long", limit=longTP)
strategy.exit("Stop Loss", "Long", stop=longSL)
// Grafikda trend chizig'ini chizish
plot(trendLine, title="Trend Line", color=color.blue, linewidth=2)
// Signal chizish
plotshape(longSignal, style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
// SL va TP darajalarini ko'rsatish
// if longSignal
// // SL chizig'i
// line.new(bar_index, longSL, bar_index + 1, longSL, color=color.red, width=2, style=line.style_dashed)
// // TP chizig'i
// line.new(bar_index, longTP, bar_index + 1, longTP, color=color.green, width=2, style=line.style_dashed)
// // SL va TP label'larini ko'rsatish
// label.new(bar_index, longSL, "SL: " + str.tostring(longSL), color=color.red, style=label.style_label_down, textcolor=color.white, size=size.small)
// label.new(bar_index, longTP, "TP: " + str.tostring(longTP), color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small)