Reply To: Average of all bars

Optuma Forums Optuma Scripting Average of all bars Reply To: Average of all bars

  • Topics: 5
  • Replies: 430
  • Posts: 435


You could do this using the BARCOUNT() function set as a dynamic bar variable.  The Bars= setting of the average would then reference this item, as per the following example…

In this script, the Moving Average is based on the number of bars the chart has available. We then see an average of all of the charts closing prices.

I use the Last() so that the value displays as a Horizontal Line on the chart (using a Show Plot).

The results will change based on the number of bars each chart has.

   The average in this example is using a bar number of 6369.

You should be able to take this example and build on it for your required purposes.

1 user thanked author for this post.

Pin It on Pinterest