Announcement

Collapse
No announcement yet.

A simple Moving Average not simple?

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

  • A simple Moving Average not simple?

    If
    return sma(14,close());

    gives me the 14 period simple moving average, why does

    return sma(14,(close(-1));

    not give me a displaced 14 period moving average,
    or

    return sma(14, open() - close())

    not give me the 14 period average of the difference?

    I am missing something?
    Thank you for helping me with what should be very simple stuff!
    Joe

  • #2
    joemeyer
    You are not getting an average because close(-1) and open()-close() are values and not series which are instead required as a source by a builtin study.
    In the first case if you want to displace the average you could use either of the following
    sma(14, close(),-1)
    or
    offsetSeries(sma(14,close()),1)
    In the second case you would need to compute your open()-close() equation in a separate function and then call that function using efsInternal() to create the series which you can pass to the sma() function.
    For more information and examples on the use of efsInternal() see also this thread
    Alex

    Comment

    Working...
    X