Average of all bars

Optuma Forums Optuma Scripting Average of all bars

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #66091
    • Topics: 65
    • Replies: 55
    • Posts: 120

    Hii Sir,

    Is there a formula to calculate average of an observation for example i want to calculate average of log returns for all the data available for any given stock and all stocks have different data. I know there is moving average but in that i need to input a value.


    • 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.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest