Help with Average calculation

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #45726 quote
    ecobravo
    Participant
    New

    Hello,
    I have following code snippet:

    RETURN Average(Close - x)

    x is a variable which I set before, however, x is not relevant for my question.

    Actually, the formula was a typo when I first entered it, because according to the documentation I should have specified the range for which the Average has to be computed in brackets, like “Average[range]”.

    However the formula works without error but I don’t know exactly what Average is being computed.

    So, which average is the formula referring to without the brackets? Is it the average of all available data?

    I would be very happy if somebody could answer my question.

    Best regards
    Ekki

    #45728 quote
    Despair
    Blocked
    Master

    This is a quite unusual way to use average command and I have a hard time seeing what you want to achieve. Maybe it is easier for you describe it in german in the german forum?

    The usual syntax is:

    c=Average[20](close)

    This will for example give you the 20-period simple moving average of the closing price.

    #45730 quote
    robertogozzi
    Moderator
    Master

    Maybe you want to calculate an average on a price, such as close, +- n Pips.

    I think you may try

    RETURN Average[10](close - (5 * pipsize))
    #45734 quote
    ecobravo
    Participant
    New

    Thanks Despair,

    like I wrote in my post, the formula like I entered it was a typo, because I omitted the brackets by mistake. It was not purposely an unusual way to use it.

    However, in the meantime I found out that the Average function defaults to a period of 20. So Average(…) gives the same result as Average[20](…), which answers my question.

    Thank you Roberto, I understand the Average function and I know how to use it – maybe my question wasn’t very clear on that.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Help with Average calculation


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
ecobravo @ecobravo Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by ecobravo
8 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/07/2017
Status: Active
Attachments: No files
Logo Logo
Loading...