Announcement

Collapse
No announcement yet.

sma(30,low(-1)) null ??

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

  • sma(30,low(-1)) null ??

    why is the result of sma(30,low(-1)) null ?? sma(30,low()) is working...

  • #2
    Re: stupid question

    zotti
    Because low(-1) is a value and not a series [as required by the sma() function for that to be used as a source] the efs engine interprets that value as a bar index parameter and not as the source parameter [since the latter is optional].
    Let us assume for example that the value returned by low(-1) is 15.00 then sma(30, low(-1)) is the same as writing sma(30, 15) ie you are retrieving the value of the 30 period simple moving average 15 bars forward relative to the bar being processed. On any bar past bar index -14 that would return null as that data does not exist
    If you are trying to directly retrieve the value at the prior bar of a 30 period simple moving average based on the low then you should write it as follows
    sma(30, low(), -1)
    You may want to see this thread for a complete series of examples on how to write the efs2 functions
    Alex


    Originally posted by zottl
    why is the result of sma(30,low(-1)) null ?? sma(30,low()) is working...

    Comment


    • #3
      because low(-1) points to a single bar (the low of the last bar) while low() points to a series of lows.

      If you want to know that the SMA value is for the last bar, then you need to use getValue(-1) to retrieve it... like...

      var vSMA = sma(30, low());

      var TheSMAvalueforthelastbaris = vSMA.getValue(-1);
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        thanks to you both for your quick help

        Comment

        Working...
        X