When the crossover between EMA25 and EMA50 happens, I would like to fill in the empty space with a red and green that is see-through.
I know I can use fill()
, but I am just not sure how.
//@version=4
strategy("My Script", overlay=true)
EMA25 = ema(close, 25)
EMA50 = ema(close, 50)
bull_cross = crossover( EMA25, EMA50)
bear_cross = crossover( EMA50, EMA25)
plot(EMA25, title="EMA(25)", color=color.orange, linewidth=9 )
plot(EMA50, title="EMA(50)", color=color.purple, linewidth=9 )
Here you go...
//@version=4
strategy("EMA Shadow", overlay=true)
EMA25 = ema(close, 25)
EMA50 = ema(close, 50)
bull_cross = crossover( EMA25, EMA50)
bear_cross = crossover( EMA50, EMA25)
a = plot(EMA25, title="EMA(25)", color=color.orange, linewidth=9 )
b = plot(EMA50, title="EMA(50)", color=color.purple, linewidth=9 )
var color col = na
col := EMA25 > EMA50 ? color.green : color.red
fill(a,b,color=col,transp=40)
The trick is to assign your plots for both EMAs to a variable and use those variables in the fill() function.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments