This strategy is a trend following trading system based on the Volatility Stop (VStop) indicator and Exponential Moving Average (EMA). Incorporating Stan Weinstein’s trading principles, it optimizes capital management through dynamically adjusted stop losses while using EMA to confirm trend direction. This combination provides investors and swing traders with a framework that can both capture trends and effectively manage risks.
The core logic is built on two main technical indicators: 1. Volatility Stop (VStop): A dynamic stop-loss indicator based on ATR (Average True Range) that adapts to market volatility. When price is in an uptrend, the stop line moves up with price; when the trend reverses, the stop line switches direction and recalculates.
Trade signal generation logic: - Entry conditions: Price above VStop (in uptrend) and closing price above EMA - Exit conditions: When closing price falls below EMA - Risk control: Real-time stop-loss positions provided by dynamically adjusted VStop
This strategy constructs a complete trend following trading framework by combining volatility stops and moving average systems. Its main advantages lie in adaptability and risk management capabilities, but attention must be paid to the impact of market environment on strategy performance. Through continuous optimization and improvement, the strategy has the potential to maintain stable performance in different market environments. Traders are advised to thoroughly test parameter settings and adjust the strategy according to their risk tolerance before live trading.
/*backtest start: 2024-12-17 00:00:00 end: 2025-01-16 00:00:00 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}] */ //@version=5 strategy("VStop + EMA Strategy", overlay=true) // VStop Parameters length = input.int(20, "VStop Length", minval=2) multiplier = input.float(2.0, "VStop Multiplier", minval=0.25, step=0.25) // EMA Parameters emaLength = input.int(30, "EMA Length", minval=1) // VStop Calculation volStop(src, atrlen, atrfactor) => if not na(src) var max = src var min = src var uptrend = true var float stop = na atrM = nz(ta.atr(atrlen) * atrfactor, ta.tr) max := math.max(max, src) min := math.min(min, src) stop := nz(uptrend ? math.max(stop, max - atrM) : math.min(stop, min + atrM), src) uptrend := src - stop >= 0.0 if uptrend != uptrend[1] and not barstate.isfirst max := src min := src stop := uptrend ? max - atrM : min + atrM [stop, uptrend] // Calculate VStop [vStop, isUptrend] = volStop(close, length, multiplier) // Plot VStop plot(vStop, "Volatility Stop", style=plot.style_cross, color=isUptrend ? color.teal : color.red) // Calculate 30 EMA emaValue = ta.ema(close, emaLength) plot(emaValue, "EMA", color=color.blue) // Entry and Exit Conditions longCondition = isUptrend and close > emaValue exitCondition = close <= emaValue // Strategy Execution if longCondition and not strategy.opentrades strategy.entry("Long", strategy.long) if exitCondition and strategy.opentrades strategy.close("Long") // Display Strategy Info bgcolor(isUptrend ? color.new(color.teal, 90) : color.new(color.red, 90), title="Trend Background")