This strategy is based on the Super Trend indicator and price channel indicator, combined with moving average signals for trading. Its core idea is to use the price channel to judge whether the current price is in an abnormal state, the Super Trend to determine the current trend direction, and generate trading signals in combination with the moving average signals.
Calculate the Super Trend indicator. The upper and lower rails are the current price plus/minus N times the ATR indicator respectively. When the price is higher than the upper rail, it is bullish. When the price is lower than the lower rail, it is bearish.
Calculate the price channel indicator. The price channel line is M times the N-day standard deviation of the price. Prices higher/lower than the channel line are considered abnormal states.
Calculate moving averages. Take the average lines of open price, close price and Super Trend respectively.
Generate trading signals:
Buy signal: Close price crosses above Super Trend line and is higher than open price moving average.
Sell signal: Close price crosses below Super Trend line and is lower than open price moving average.
Set stop loss and take profit price channel.
Combining multiple indicators avoids false signals.
Using price channel to judge abnormal price states can filter out some undesirable entry points.
Moving averages combined with judging trend direction avoid trading against the trend.
Setting stop loss and take profit range controls risk.
Parameter settings are too subjective and need optimization.
Stop loss and take profit range may be set too wide or too narrow.
Price channel parameters may not suit all products, separate testing is needed.
Significant losses may occur during drastic trend changes.
Test and optimize parameters to find optimal combinations.
Test moving averages with different periods to select optimal parameters.
Backtest on multiple products and select parameters according to performance respectively.
Optimize stop loss strategy to avoid excessively large single loss.
This strategy combines multiple indicators to judge price abnormalities and trend directions, which can theoretically filter out some false signals. However, parameter settings are still relatively subjective with room for optimization. In addition, trading costs like commissions and slippage should be considered in actual trading. Overall, this strategy is more suitable as a trend following strategy, but parameters need to be optimized and adjusted for different products.
/*backtest start: 2023-12-10 00:00:00 end: 2023-12-11 00:00:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy(title="Vol ST VM", overlay=true) source = close hilow = ((high - low)*100) openclose = ((close - open)*100) vol = (volume / hilow) spreadvol = (openclose * vol) VPT = spreadvol + cum(spreadvol) window_len = 28 v_len = 14 price_spread = stdev(high-low, window_len) v = spreadvol + cum(spreadvol) smooth = sma(v, v_len) v_spread = stdev(v - smooth, window_len) shadow = (v - smooth) / v_spread * price_spread out = shadow > 0 ? high + shadow : low + shadow // src = out src1=open src2=low src3=high tf =input(720) len = timeframe.isintraday and timeframe.multiplier >= 1 ? tf / timeframe.multiplier * 7 : timeframe.isintraday and timeframe.multiplier < 60 ? 60 / timeframe.multiplier * 24 * 7 : 7 c = ema(src, len) plot(c,color=color.red) o = ema(src1,len) plot(o,color=color.blue) //h = ema(src3,len) //l=ema(src2,len) // col=c > o? color.lime : color.orange vis = true vl = c ll = o m1 = plot(vl, color=col, linewidth=1, transp=60) m2 = plot(vis ? ll : na, color=col, linewidth=2, transp=80) fill(m1, m2, color=col, transp=70) // vpt=ema(out,len) // INPUTS // st_mult = input(1, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01) st_period = input(10, title = 'SuperTrend Period', minval = 1) // CALCULATIONS // up_lev = vpt - (st_mult * atr(st_period)) dn_lev = vpt + (st_mult * atr(st_period)) up_trend = 0.0 up_trend := close[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev down_trend = 0.0 down_trend := close[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev // Calculate trend var trend = 0 trend := close > down_trend[1] ? 1: close < up_trend[1] ? -1 : nz(trend[1], 1) // Calculate SuperTrend Line st_line = trend ==1 ? up_trend : down_trend // Plotting plot(st_line[1], color = trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend") buy=crossover( close, st_line) and close>o sell=crossunder(close, st_line) and close<o //plotshape(crossover( close, st_line), location = location.belowbar, color = color.green,size=size.tiny) //plotshape(crossunder(close, st_line), location = location.abovebar, color = color.red,size=size.tiny) plotshape(buy, title="buy", color=color.green, style=shape.arrowup, location=location.belowbar, size=size.normal, textcolor=color.white, transp=0) //plot for buy icon plotshape(sell, title="sell", color=color.red, style=shape.arrowdown, location=location.abovebar, size=size.normal, textcolor=color.white, transp=0) //plot for sell icon // multiplier = input(title="TP", type=input.float, defval=2, minval=1) src5 = close len5 = input(title="TP length", defval=150, minval=1) offset = 0 calcSlope(src5, len5) => sumX = 0.0 sumY = 0.0 sumXSqr = 0.0 sumXY = 0.0 for i = 1 to len5 val = src5[len5-i] per = i + 1.0 sumX := sumX + per sumY := sumY + val sumXSqr := sumXSqr + per * per sumXY := sumXY + val * per slope = (len5 * sumXY - sumX * sumY) / (len5 * sumXSqr - sumX * sumX) average = sumY / len5 intercept = average - slope * sumX / len5 + slope [slope, average, intercept] var float tmp = na [s, a, i] = calcSlope(src5, len5) vwap1=(i + s * (len5 - offset)) sdev = stdev(close, len5) dev = multiplier * sdev top=vwap1+dev bott=vwap1-dev // z1 = vwap1 + dev x1 = vwap1 - dev low1 = crossover(close, x1) high1 = crossunder(close, z1) plotshape(low1, title="low", text="TP", color=color.red, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0) //plot for buy icon plotshape(high1, title="high", text="TP", color=color.green, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0) //plot for sell icon strategy.entry(id="Enter Long MA", long=true, comment="Buy", when=high1) strategy.entry(id="Short Entry MA", long=false, comment="Sell", when=low1) /////// Alerts ///// alertcondition(buy,title="buy") alertcondition(sell,title="sell") alertcondition(low1,title="sell tp") alertcondition(high1,title="buy tp")