EMA crosses ema3,ema9,ema20,ema50

Good morning, I would like to create an indicator that highlights in orange whenever EMA3, EMA9, EMA20, and EMA50 cross each other. It doesn't matter which EMA crosses with which; if there is a crossover, it should be highlighted in orange. Best regards.

1 Like
ema3 = EMA( C, 3 );
ema9 = EMA( C, 9 );
ema20 = EMA( C, 20 );
ema50 = EMA( C, 50 );

cr1 = Cross( ema3, ema9 );
cr2 = Cross( ema3, ema20 );
cr3 = Cross( ema3, ema50 );
cr4 = Cross( ema9, ema20 );
cr5 = Cross( ema9, ema50 );
cr6 = Cross( ema20, ema50 );

AnyCrossUp = cr1 OR cr2 OR cr3 OR cr4 OR cr5 OR cr6;

color = IIF( AnyCrossUp, colorOrange, colorDefault );

// use color variable for any Plot you wish to color

That is for cross up.
Coding for cross down is left as exercise to the reader.

5 Likes