Adaptive Moving Average (AMA)

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #121959 quote
    NicolasNicolas
    Keymaster
    Legend

    This code is an oscillator, not an indicator to put on the price chart.

    #121961 quote
    DenisDenis
    Participant
    Senior

    I am not very gifted but I know that 😉

    It is below the price chart

    #121965 quote
    DenisDenis
    Participant
    Senior

    Here is my chart

    Only “Indicateur” appears

    PXI-5-minutes.png PXI-5-minutes.png
    #121967 quote
    NicolasNicolas
    Keymaster
    Legend

    Try this version:

    //variable p =période de la moyenne
    //smooth1=période de lissage
    //smooth2=période du signal
    
    p = 20
    smooth1 = 3
    
    if barindex>p+smooth1 then 
    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
    endif
    
    return b1 coloured by momentum[1](b1) AS "Indicateur",0 as "Zero", kama as "Signal"
    
    ////////////////////////FIN du code
    #121970 quote
    DenisDenis
    Participant
    Senior

    Too strong Nicolas! It works well.

    So he was just missing an “endif” ?

    A big thank you anyway and have a nice evening

    #121972 quote
    NicolasNicolas
    Keymaster
    Legend

    lines 8 and 31 were added. I embed the whole code in a condition to check there are sufficient bars to complete the calculation.

    #121973 quote
    DenisDenis
    Participant
    Senior

    When I say it was missing an endif, I mean it was missing an initialization

    #121976 quote
    DenisDenis
    Participant
    Senior

    I saw Nicolas, thank you again. Have a nice evening.

    #126857 quote
    mlouysmlouys
    Participant
    Junior

    Hello

    When I add the kama ( or the ama) code next to the macd ZL code, I have a error message, don t know why … Here is the code

    //moyenne mobile adaptative
    
    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
    
    
    // MACD ZLag
    
    // --- settings
    short = 12
    long = 26
    signal = 9
    
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
     
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
     
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
     
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
     
    SignalMACD=signal1+DIFFERENCE2

    Error message on the screen:  ”  erreur de syntaxe une des expressions suivantes serait plus adaptés que “short” probuilder.error.suggestion.EOF “\n”  ”

    An idea ? Many thanks in advance

    Michel

    #126860 quote
    mlouysmlouys
    Participant
    Junior

    Ok sorry I think I found my mistable reading it another time …

    return kama was tooo much

    Sorry !

Viewing 10 posts - 16 through 25 (of 25 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 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 mlouysmlouys
6 years, 5 months ago.

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