MA Crossover within certain bars

Hello Friends,

I need your help in creating an exploration for 2 or 3 MA that are stacked positive within certain number of bars.

For example... for 3 SMA i.e. 21, 50 and 100 are stacked up i.e. 21>50>100 within last 20 bars, so it should be within last 1, 2, 10 or 20 bars, then how do i code for that and get a list of stocks that are having this condition true within 20 bars.

Your help is much appreciated.

Thank you

ma1 = MA(C,21);
ma2 = MA(C,50);
ma3 = MA(C,100);

cond = ma1 > ma2 AND ma2 > ma3;
bars = BarsSince(! cond);

// sample Exploration filter
Filter = bars > 10 AND bars < 20;
1 Like

Thank you very much @fxshrat for helping me out. This is a big help my friend. I really appreciate your quick response and help :slight_smile: :pray:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.