GRADIENT IN SMA

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #132914 quote
    steynpj
    Participant
    Average

    I would like to code a rough gradient in a moving average. My clumsy idea was to try code the SMA, must be higher than SMA of 5 periods ago plus a value, which is X below.

    indicator5 = Average[C](close)
    indicator6 = Average[C](close)
    c3 = (indicator5 > indicator6[5]+X)

    Above not working.

     

    Help appreciated

    #132916 quote
    robertogozzi
    Moderator
    Master

    Try

    c3 = (indicator5 - indicator6[5]+X)

    This could also help https://www.prorealcode.com/reply/70279/

    #132936 quote
    steynpj
    Participant
    Average

    Thank you.

     

    Does not seem to work

    #132945 quote
    Vonasi
    Moderator
    Master

    The best way to measure a gradient is with a ratio of y and x.

    c = 100
    x = 5
    y = average[c] - average[c](close[x-1])
    
    Ratio = (y/x)

    Negative ratio results are a downward sloping MA and the lower the number the steeper the angle. Positive ratio results are an upward sloping MA and the greater the number the steeper the angle.

    #132947 quote
    Vonasi
    Moderator
    Master

    If you convert it to a percentage of the average p bars back then it is even more usable.

    p = 100 
    x = 5 
    y = average[p] - average[p](close[x-1]) 
    Ratio = ((y/x)/average[p](close[x-1]))*100
    
    return ratio
    
    nonetheless and GraHal thanked this post
    #132959 quote
    GraHal
    Participant
    Master

    Above added as Log 217 here …

    Snippet Link Library

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

GRADIENT IN SMA


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
steynpj @steynpj Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by GraHal
5 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/23/2020
Status: Active
Attachments: No files
Logo Logo
Loading...