Average a moving averages difference?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #91573 quote
    Maisam Zaidi
    Participant
    Junior

    Hello Everyone,

    I have recently studied the ProBuilder Manual and found it very exciting and helpful. However, I tried to code something and it is giving me an error which I am unable to rectify.

    Here is the code:

    // Faster Average = 8
    // Slower Average = 18
    // Difference Period = 9
    
    fastAvg = Average[8](close)
    slowAvg = Average[18](close)
    differencePeriod = 9
    
    trendDifference = fastAvg - slowAvg
    differenceAvg = Average(trendDifference, differencePeriod)
    
    RETURN trendDifference AS "Trend Difference", differenceAvg AS "Difference Average"

    The problem is with the differenceAvg line. I want to get the average of both trendDifference and differencePeriod but unable to do so.

    Can anyone please guide me how to rectify this problem.

    Thanks in advance.

    I also have attached the image.

    Regards,
    Maisam

    Capture-1.jpg Capture-1.jpg
    #91576 quote
    Vonasi
    Moderator
    Master

    You cannot use AVERAGE as you have done. Simply do this:

    differenceAvg = (trendDifference + differencePeriod) / 2
    #91580 quote
    Nicolas
    Keymaster
    Master

    Another “code help” labelled topic. We should declare it as the only one valid name for topics, it would save me soooooo much time! :devil:

    #91581 quote
    Maisam Zaidi
    Participant
    Junior

    Thanks very much @Vonasi. Very quick reply. Really appreciate it.


    @Nicolas
    – Really sorry about that. I will try to be more careful next time.

    Regards,
    Maisam

    #91582 quote
    Vonasi
    Moderator
    Master

    Another “code help” labelled topic.

    Ooops….. was going to correct that but forgot to do it after I’d replied!

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

Average a moving averages difference?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Maisam Zaidi @maisam Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Vonasi
6 years, 12 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/17/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...