Bars that contain multiple MAs


I am looking at using multiple moving averages and in particular I am looking at finding any bars such that all moving averages pass through that bar.

That is – I would like to highlight situations where the moving averages 'squeeze' together so that all moving averages pass through a single bar.

Generally speaking – something along the lines of the following

V1 = MA(5)

V2 = MA(10)

V3 = MA(15)

Is the high of the current bar above V1 and V2 and V3 AND the low of the current bar below V1 and V2 and V3

If it is, then return a positive value



Hi Steve,

Try something like this:


V1 = MA(BARS=5, CALC=Close);
V2 = MA(BARS=10, CALC=Close);
V3 = MA(BARS=15, CALC=Close);

V1 > LOW() and V1 < HIGH() and
V2 > LOW() and V2 < HIGH() and 
V3 > LOW() and V3 < HIGH()



I have created my own 'moving averages' using a script. Is it possible to obtain the same result using a script in place of a default style moving average (ie determining where the custom moving averages all converge and pass through a single bar)

Is one script able to call upon another script - or is there another way to get the same result?



Hi Steve,

You can use a Show Plot to plot a value on the same scale as the price chart, and you can use the SCRIPT() function to reference a previously created (and saved) script.