Announcement

Collapse
No announcement yet.

Moving average question

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

  • Moving average question

    I am new to using EFS and have a simple question. The moving average example in the library sums the data and divides by the number of data points and plots the value on the last data point ( end centered average).
    How do I modify this to plot the value on the centeral point of the data for an odd numbered average?( Centered moving average )

    Thank you

    Alan

  • #2
    Alan
    I believe that in a centered moving average you round up the fractional value
    Alex

    Comment


    • #3
      Every study I look at in the libray and other locations always plot the calculated value on the lst bar. The problem I have is a centered moving average needs to be plotted several bars back from the last bar. ( A centered moving average of 5 data points is ploted on the 3 data point. ) When I try to use offset, it plots the data point correctly but does not refresh for the next bar.

      Comment


      • #4
        Alan
        The Moving Averages studies in Basic Studies will update even when a negative offset is applied so you could use those.
        An efs instead does not automatically update a plot on past values if a negative offset is used (although it still computes those values correctly) so you need to use the setBar() command to force it to update the plot.
        You can see how this is done in the attached efs which computes a 5 period Centered MA (ie offset by -3).
        In Edit Studies you have an option to "Center" the MA or not. If you select Yes then the script will automatically compute and apply the appropriate negative offset. If you select No you can still apply a positive or negative offset manually. In either case the plot should update on the chart
        Alex
        Attached Files

        Comment

        Working...
        X