#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# need help with this weekly scan....

edited December 2015 in Scanning
The syntax I am trying to write is for this line...
"The last 10 or more weekly closings are less than the 30 week SMA"

• mod
edited December 2015
If I remember correctly @Gord 's answers about using MACD to compare MAs and closes - if you are OK with an EMA instead of an SMA, you could write

and [max(10, MACD Hist(1,30,0)) < 0]

Add MACD Hist(1,30,0) to a chart, along with a 1 period EMA and a 30 period EMA to verify the results.

The first two parameters are the lengths of two EMAs (MACD only takes EMAs). The third parameter is an average of the difference between the two emas If that third parameter is 0, the indicator displays just the raw difference between the first two emas. As long as that difference is above zero, the first EMA (1) is above the second (30) EMA; if the difference is below zero, the first is below the second (this assumes the first EMA is the shorter EMA).

A 1 period EMA is the same as the close, so this combination of EMAs will display the difference between the close and the EMA.

So the above scan says the maximum difference between the two EMAs (1 and 30) has not exceeded 0 for the last 10 periods. Remember we are dealing with negative numbers, so "smaller" negative numbers are actually greater, e.g. -5 is greater than -10, so we have to use max() even though the Hist bar for -5 would be shorter than -10 on the indicator display.

• mod
Sorry, that should be

and [max(10, weekly MACD Hist(1,30,0)) < 0]