Average of all bars

Optuma Forums Optuma Scripting Average of all bars

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #66091
    Deepak
    • 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.

    Regards,
    Deepak

    #66095
    Matthew
    • Topics: 5
    • Replies: 430
    • Posts: 435

    Hi,

    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.

    Ex2
       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