Announcement

Collapse
No announcement yet.

Question regarding how efs calculates SMA

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question regarding how efs calculates SMA

    Hi: I have a question regardiing how efs calculates a double or triple sma, or ema for that matter. For example the following line of code:

    myStudy = sma(3,sma(5,close()));

    How will efs evaluate this expression? From my understanding this is what I'm assuming is going to happen, please correct me if I'm wrong.

    Lets say we have the following set of closing prices S = {P0, P1, P2,...,PN} where P0 is the most recent closing price. First efs will evaluate the inner sma:

    sma(5,close());

    Becomes: [P0+P1+P2+P3+P4]/5 = X1. But due to the fact that the outer expression sma(3,...) requires three values to calculate the average. The inner expression will move one price forward and evaluate X2 = [P1+P2+...+P5]/5 and X3 = [P2+...+P6]/5. Hence, we now have a new set of values T = {X1,X2,X3}. Therefore:

    sma(3,sma(5,close()) = sma(3,T) = sma(3, {X1,X2,X3}) = [X1+X2+X3]/3

    Is this correct? Thanks to anyone who responds!

  • #2
    goodsz
    When computing nested functions the efs engine executes them starting from the innermost function.
    In your sma(3, sma(5, close())) example it will first compute the 5 period moving average of the Close and then the 3 period moving average of that average.
    Alex

    Comment

    Working...
    X