Adaptive Moving Average (AMA)

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #64121 quote
    Guckus
    Participant
    New

    Dear All:

    is there any code for the AMA indicator available?

    #64147 quote
    Despair
    Blocked
    Master

    There are several adaptive MAs. One e.g. is the KAMA and has even installed PRT since version 10.3 (called adaptive moving average). Then there are probably some more adaptive MA’s in the library.

    #101132 quote
    Nicolas
    Keymaster
    Master

    This adaptive moving average in ProRealTime is the same as KAMA:

    // parameters :
    Period = 10
    FastPeriod = 2
    SlowPeriod = 30
    
    Fastest = 2 / (FastPeriod + 1)
    Slowest = 2 / (SlowPeriod + 1)
    if barindex < Period+1 then
    Kama=close
    else
    Num = abs(close-close[Period])
    Den = summation[Period](abs(close-close[1]))
    ER = Num / Den
    Alpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)
    KAMA = (Alpha * Close) + ((1 -Alpha)* Kama[1])
    endif
    
    return kama
    #113972 quote
    Jan
    Participant
    Veteran

    Good evening,

    I have found an (the?) calculation of the AMA and coded it below in PRT.

    AMA follows the actual price movements faster as KAMA does

    I can mention the source where I found it if required.

    // Variables:
    Per = 10
    Fast = 2
    Slow = 30
    
    //multiplier calculation
    MLTP = ABS((Close - Lowest[Per](Low)) - (Highest[Per](High) - Close)) / ((Highest[Per](High) - Lowest[Per](Low)))
    //smoothing multiplier
    SC = SQUARE (MLTP * (Fast/(Fast+1) - Fast/(Slow+1)) + Fast/(Slow+1))
    //calculation of AMA
    if barindex <= Per + 1 then
    AMA = close
    else
    //The first AMA is the close. The current AMA can be calculated using this formula:
    AMA = AMA[1] + SC * (Close - AMA[1])
    endif
    
    return AMA
    
    Vonasi thanked this post
    #121926 quote
    Denis
    Participant
    Senior

    Hello Nicolas,

    I would like to use the adaptive moving average, not on prices but on an indicator.

    Is it possible to adapt the above codes by replacing “Close” with the name of the indicator?

    In advance, a thousand thanks for your always precious help.

    NB:

    I am using V10 via IG and therefore cannot use the adaptive code [9,2,30] (close) available in V11.

    Good apm

    Denis

    #121927 quote
    Vonasi
    Moderator
    Master

    Denis – Please post only in the language of the forum that you are posting in – English only in the English speaking forums please.

    #121928 quote
    Denis
    Participant
    Senior

    OK, sorry

    #121931 quote
    Vonasi
    Moderator
    Master

    I already translated your French post to English so there is no need to post it again. You also posted it in the ‘Insert PRT Code’ box for some strange reason so I have deleted your last post. Please try to be more careful when posting in the forums – we like to keep them tidy! 🙂

    #121933 quote
    Denis
    Participant
    Senior

    OK, sorry. I don’t know what is ‘Insert PRT Code’. Maybe a wrong maneuver.

    #121937 quote
    Nicolas
    Keymaster
    Master

    Is it possible to adapt the above codes by replacing “Close” with the name of the indicator?

    Yes it is possible, replace “Close” with the variable that contains the values of your indicator.

    #121938 quote
    Denis
    Participant
    Senior

    Many thanks Nicolas, I did it. I was able to validate the code but no line appears on the graph while the AMA appears well in the properties of he indicator.

    #121948 quote
    Nicolas
    Keymaster
    Master

    Please post the code in order to fix it. It’s probably a lack of history for the indicator to compute correctly at first run.

    #121949 quote
    Denis
    Participant
    Senior
    //variable p =période de la moyenne
    //smooth1=période de lissage
    //smooth2=période du signal
    
    a=average[p](customclose)
    r=round(p/2) +1
    b= customclose - a[r]
    
    b1=average[smooth1](b)
    
    // parameters :
    Period = 10
    FastPeriod = 2
    SlowPeriod = 30
     
    Fastest = 2 / (FastPeriod + 1)
    Slowest = 2 / (SlowPeriod + 1)
    if barindex < Period+1 then
    Kama=b1
    else
    Num = abs(b1-b1[Period])
    Den = summation[Period](abs(b1-b1[1]))
    ER = Num / Den
    Alpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)
    KAMA = (Alpha * b1) + ((1 -Alpha)* Kama[1])
    endif
    
    return b1 coloured by momentum[1](b1) AS "Indicateur",0 as "Zero", kama as "Signal"
    
    ////////////////////////FIN du code

    Here is the code Nicolas

    #121950 quote
    Nicolas
    Keymaster
    Master

    It works quite well for me. I just added these settings at top of the code:

    p = 20
    smooth1 = 3
    #121957 quote
    Denis
    Participant
    Senior

    Thanks Nicolas

    “p” and “smooth1” are variables in my code so it should be the same as define them at top of the code ?

    I have tried with settings at top of the code but the KAMA does not appear, I don’t understand why

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

Adaptive Moving Average (AMA)


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Guckus @guckus Participant
Summary

This topic contains 24 replies,
has 7 voices, and was last updated by mlouys
5 years, 10 months ago.

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