This strategy is constructed based on the Average True Range (ATR) indicator to build a SuperTrend line for judging market trend direction and generating trading signals. It has both trend judgment and trend tracking capabilities, applicable to indices futures, forex, and cryptocurrencies.
The strategy calculates the ATR over a certain period and compares it with price to determine if the price is within an uptrend channel. Specifically, it first computes the ATR, then uses the ATR value multiplied by a factor to plot the upper and lower bands. When the price is higher than the upper band, an uptrend is identified. When the price is below the lower band, a downtrend is identified. In an uptrend, if the price changes from downtrend to uptrend, a buy signal is generated. In a downtrend, if the price changes from uptrend to downtrend, a sell signal is triggered.
The key lies in constructing the trend judgment benchmark - SuperTrend line. The SuperTrend line is based on the dynamically changing ATR, which can effectively filter out market noise and determine the major trend direction. Meanwhile, the SuperTrend line has a certain lagging effect, which helps confirm trend reversal points and avoid generating incorrect trading signals.
The biggest advantage of this strategy is the combination of trend identification and tracking abilities:
The main risks of this strategy include:
Possible solutions include optimizing parameters like ATR period and SuperTrend factor, combining with other indicators for verification, and reducing incorrect signal probabilities. Also, stop losses can control single trade loss.
Further optimization space exists in areas like:
In-depth optimization promises to further lift stability, adaptiveness and profitability of the strategy.
The strategy demonstrates great stability, reliability and profitability overall. Constructing the SuperTrend line for major trend judgment and trading signals is its biggest highlight. But certain degree of lagging effect and misjudgment risks do exist. Parameter and model optimization promises better strategy performance. In summary, as a typical trend-based strategy, it is worthwhile to verify and utilize it in live trading.
/*backtest start: 2022-12-01 00:00:00 end: 2023-12-07 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy("Supertrend Strategy", overlay = true) Periods = input(10, title="ATR Period") src = input(hl2, title="Source") Multiplier = input(3.0, title="ATR Multiplier", step=0.1) changeATR = input(true, title="Change ATR Calculation Method?") showsignals = input(true, title="Show Buy/Sell Signals?") highlighting = input(true, title="Highlighter On/Off?") atr2 = sma(tr, Periods) atr = changeATR ? atr(Periods) : atr2 up = src - (Multiplier * atr) up1 = nz(up[1], up) up := close[1] > up1 ? max(up, up1) : up dn = src + (Multiplier * atr) dn1 = nz(dn[1], dn) dn := close[1] < dn1 ? min(dn, dn1) : dn trend = 1 trend := nz(trend[1], trend) trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green) buySignal = trend == 1 and trend[1] == -1 plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red) sellSignal = trend == -1 and trend[1] == 1 plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0) mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0) longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white fill(mPlot, upPlot, title="UpTrend Highlighter", color=longFillColor) fill(mPlot, dnPlot, title="DownTrend Highlighter", color=shortFillColor) strategy.entry("Buy", strategy.long, when=buySignal) strategy.entry("Sell", strategy.short, when=sellSignal) alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!") alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!") changeCond = trend != trend[1] alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")