//@version=5 strategy("Elliott Wave with Bollinger Bands", overlay=true) // Input parameters deviation = input(2, title="Bollinger Bands Deviation") // Calculate Bollinger Bands smaValue = ta.sma(close, 15) upperBand = smaValue + deviation * ta.stdev(close, 15) lowerBand = smaValue - deviation * ta.stdev(close, 15) // Elliott Wave labels var int waveCount = na var int lastWaveCount = na if barstate.islast waveCount := na lastWaveCount := na if not na(waveCount) waveCount := waveCount + 1 if close > high[1] and close > high[2] waveCount := 1 if close < low[1] and close < low[2] waveCount := -1 if na(lastWaveCount) lastWaveCount := waveCount // Plot Bollinger Bands plot(upperBand, color=color.green, title="Upper Band") plot(lowerBand, color=color.red, title="Lower Band") // Strategy rules enterLong = close > upperBand and waveCount > 0 and lastWaveCount == -1 enterShort = close < lowerBand and waveCount < 0 and lastWaveCount == 1 exitLong = close < smaValue and waveCount > 0 exitShort = close > smaValue and waveCount < 0 // Execute trades if (enterLong) strategy.entry("Long", strategy.long) if (enterShort) strategy.entry("Short", strategy.short) if (exitLong) strategy.close("Long") if (exitShort) strategy.close("Short")