GRADIENT IN SMA

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #132914 quote
    steynpjsteynpj
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    Try

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

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

    #132936 quote
    steynpjsteynpj
    Participant
    Average

    Thank you.

     

    Does not seem to work

    #132945 quote
    VonasiVonasi
    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
    VonasiVonasi
    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
    GraHalGraHal
    Participant
    Legend

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 GraHalGraHal
6 years, 4 months ago.

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