Comparing Dif Bet Two SMAs for Dif Days

Hi!

To build a scan, after I test that today's SMA (9) is above today's SMA (26) and that yesterday's SMA(9) is above yesterday's SMA(26), which I know how to do,

is there a way to test that

the difference between today's SMA(9) and today's SMA(26)

is greater than

the difference between yesterday's SMA(9) and yesterday's SMA(26)?

How do I write it?

Thank you!

Dr. T

Comments

  • If you wanted to use emas, you could just use MACD Line(9,26,9) > 1 day ago MACD Line(9,26,9).

    For sma you have to write it out, which just involves some brackets and a time modifier.

    So you have your basic condition frame work

    and [ ]

    then brackets around the first subtraction operation for today, to tell you how far apart they smas are:

    [ sma(9,close) - sma(26, close) ]

    then brackets around the second subtraction operation for yesterday (1 day ago):

    [ 1 day ago sma(9, close) - 1 day ago sma(26, close) ]

    then a comparison operator between the two subtraction operations makes it:


    and [ [ sma(9,close) - sma(26, close) ] > [ 1 day ago sma(9, close) - 1 day ago sma(26, close) ] ]
  • Dear Mark D,

    Thank you for your prompt reply.

    So the key is to use double brackets. I'll try it.

    Dr. T
  • Well, the "extra" brackets are for clarity. The scan engine's syntax doesn't require them in this case. But I always use them to group the elements of an operation, just to make it clear what you are comparing to what.