Percent Close below moving average value

Hi guys

I want to write a script to find stocks which are more than 100% below the 50 sma. I have attempted to do this using the following script but in showbar mode this script also picks up closes within 100% of 50sma. What am I doing wrong?

//Calc 50MA;
MA50 = MA(BARS=50, CALC=Close, STYLE=Simple);
//Close is below 50MA by more than !00% of 50MA value;
CLOSE() < MA50 and CLOSE() < (MA50*1.01)

Hi Tonia,

I don’t think 100% is mathematically possible, but your formula is using 1% (MA50 * 1.01)… If you are looking for when the close is within 1% below the MA50 try this:

//Calc 50MA;
MA50 = MA(BARS=50, CALC=Close, STYLE=Simple);
//Close is below 50MA but within 1% of 50MA value;
CLOSE() < MA50 and CLOSE() > MA50*0.99

The Show View tool shows the % below 50MA, so JHX is 0.82% from the 50MA:

MA50 = MA(BARS=50, CALC=Close);
((CLOSE()-MA50)/MA50) * 100

Capture