This strategy is a trend breakout trading system that combines moving averages with price breakout concepts. The core mechanism is generating trading signals based on price closes breaking above the moving average, with stop-loss levels set at recent lows and a 2:1 profit-to-loss ratio for risk management. The strategy uses a Simple Moving Average as a trend indicator and identifies trend changes through price-line crossovers.
The strategy employs a 20-period Simple Moving Average (SMA) as a trend indicator. Long signals are generated when the closing price breaks above the moving average from below. Stop-loss levels are set at the lowest point of the past 7 candles to avoid placing them too close to entry points. Take-profit levels are set using a classic 2:1 reward-to-risk ratio, meaning the profit target is twice the distance of the stop-loss. The strategy includes visualization components that mark trend lines, trading signals, and stop-loss/take-profit levels on the chart.
This is a well-structured trend-following strategy with clear logic. It generates signals through moving average breakouts, combined with reasonable risk management mechanisms, making it practically applicable. While inherent risks exist, the suggested optimization directions can further enhance strategy stability and profitability. The strategy is suitable for trending market conditions, and traders can adjust parameters according to specific market characteristics.
/*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)