OPEN-SOURCE SCRIPT

Double EMA Crossover with Volume Filter

//version=5
indicator("Double EMA Crossover with Volume Filter", overlay=true)

// Inputs for EMA lengths
fast_ema_length = input.int(3, title="Fast EMA Length", minval=1)
slow_ema_length = input.int(30, title="Slow EMA Length", minval=1)

// Input for Volume settings
volume_length = input.int(20, title="Volume Moving Average Length", minval=1)

// Calculate EMAs
fast_ema = ta.ema(close, fast_ema_length)
slow_ema = ta.ema(close, slow_ema_length)

// Calculate Volume Average
avg_volume = ta.sma(volume, volume_length)

// Volume condition: Current volume is higher than average volume
is_high_volume = volume > avg_volume

// EMA Crossover conditions
bullish_crossover = ta.crossover(fast_ema, slow_ema) // Fast EMA crosses above Slow EMA
bearish_crossover = ta.crossunder(fast_ema, slow_ema) // Fast EMA crosses below Slow EMA

// Combine crossover and volume condition
bullish_signal = bullish_crossover and is_high_volume
bearish_signal = bearish_crossover and is_high_volume

// Plot EMAs
plot(fast_ema, color=color.blue, linewidth=2, title="Fast EMA (3)")
plot(slow_ema, color=color.orange, linewidth=2, title="Slow EMA (30)")

// Plot signals
plotshape(bullish_signal, style=shape.labelup, color=color.green, size=size.small, location=location.belowbar, text="Buy")
plotshape(bearish_signal, style=shape.labeldown, color=color.red, size=size.small, location=location.abovebar, text="Sell")

// Highlight high-volume bars
bgcolor(is_high_volume ? color.new(color.green, 90) : na, title="High Volume Highlight")
Candlestick analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer