Adaptive Moving Averag

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #213253 quote
    MarkscraggMarkscragg
    Participant
    New

    I am trying to code a variation of Perry Kaufmans Adaptive Moving Average

    The Equation is AMA= (ER*Close) + (1-ER)*AMA[1]

    It Returns ‘Blank’

    Can anyone help?

     

    // parameter
    // n = 10
    
    Change = ABS(close - close[n])
    
    calc = ABS(close-close[1])
    
    volat = summation[n](calc)
    
    ER = Change / volat
    
    once AMA=Average[n]
    
    AMA=(ER*Close)+(1-ER)*AMA[1]
    
    //or
    
    //V1=(1-ER)
    //V2=AMA[1]
    //V3=(V1*V2)
    //AMA=(ER*Close)+V3
    
    Return AMA
    #213254 quote
    JSJS
    Participant
    Master

    Hi,

    This is how I know the Kaufman filter…

    Period = MAX(10, 4)
    
    FastPeriod = 7
    SlowPeriod = 28
    
    Fastest = 2 / (FastPeriod + 1)
    Slowest = 2 / (SlowPeriod + 1)
    
    IF BarIndex < Period 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
    #213279 quote
    MarkscraggMarkscragg
    Participant
    New
    JS Thanks for the quick reply.  However I was trying to code the following equation The Equation is AMA= (ER*Close) + (1-ER)*AMA[1] Where ER is the smoothing constantent dirived from  Perry Kaufman I think the problem lies in the second part of the equation! Regards
    #213293 quote
    NicolasNicolas
    Keymaster
    Legend
    Needs at least n data in order to calculate, so embed your code into a barindex count condition:
    // parameter
    n = 10
    
    if barindex>n then 
    Change = ABS(close - close[n])
    
    calc = ABS(close-close[1])
    
    volat = summation[n](calc)
    
    ER = Change / volat
    
    once AMA=Average[n]
    
    AMA=(ER*Close)+(1-ER)*AMA[1]
    endif 
    
    Return AMA
    #213394 quote
    MarkscraggMarkscragg
    Participant
    New
    Thank You Nicolas That seems to work I have been learning prorealcode for sometime now.  Could you recommend any text that may help me I have studied the online manuels plus the Vivian Schmitt ebook but still need more help. Regards Mark
Viewing 5 posts - 1 through 5 (of 5 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

Adaptive Moving Averag


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Markscragg @markscragg Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 04/13/2023
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...