This particular Chande’s Momentum Oscilator MMA

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #198653 quote
    MaryMary
    Participant
    Average

    [attachment file=”198654″]

    Hello, could anyone Please help translating this particular Chande Momentum Oscillator from TradingView to ProRealtime. The code is below:

     

    study(title=”[RS]Chande’s Momentum Oscilator – MMA”, shorttitle=”[RS]CMO-MMA”)
    // Notes : {
    // @author : RicardoSantos
    // Chande’s Momentum Oscilator:
    //
    // ((Su – Sd) / (Su + Sd)) * 100
    //
    // – Su is the sum of the momentum of up days in the period under analysis
    // – Sd is the sum of the momentum of down days in the period under analysis.
    // – The default period is the last 9 days.
    // }

    // Input : {
    p = input(24, title=”Period:”)
    hl = input(40, title=”Overbought:”)
    ll = input(-40, title=”Oversold:”)
    // }

    // Function : {
    s = close
    Su = sma(close > open ? s – s[1] : 0, p)
    Sd = sma(close < open ? abs(s – s[1]) : 0, p)

    cmo = ((Su – Sd)/(Su + Sd))*100
    ma1 = ema(cmo, 12)
    ma2 = ema(ma1, 24)
    ma3 = ema(ma2, 48)
    // }

    // Output : {
    // Color Switches :
    c0 = cmo > ma1 ? #337e33 : #B44949
    c1 = ma1 > cmo ? #bc5a5a : #42a242
    c2 = ma2 > cmo ? #a24242 : #5abc5a
    c3 = ma3 > cmo ? #7e3333 : #7fcb7f

    // Lines :
    plot(0, color=black, style=circles)
    p1 = plot(hl, color=#9a85b4, style=circles)
    p2 = plot(ll, color=#9a85b4, style=circles)
    fill(p1,p2, color=#9a85b4, transp=80)

    // Chande’s MO MA’s
    plot(cmo, color=c0, style=line, linewidth=2)
    plot(ma1, color=c1, style=circles, linewidth=2, join=true)
    plot(ma2, color=c2, style=circles, linewidth=2, join=true)
    plot(ma3, color=c3, style=circles, linewidth=2, join=true)
    // }

    Chande-Oscillator.png Chande-Oscillator.png
    #198662 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    This should do:

    // Chande Momentum Oscillator (CMO) - MMA
    //
    // http://www.traderpedia.it/wiki/index.php/Chande_Momentum_Oscillator
    // https://www.investopedia.com/terms/c/chandemomentumoscillator.asp
    //
    //DEFPARAM CalculateOnLastBars = 1000
    //p    = 20                  //20  periods
    //M1   = 12                  //12  Ema periods
    //M2   = 24                  //24  Ema periods
    //M3   = 48                  //48  Ema periods
    //Type = 1                   //1=Ema   (supported types 0 - 8)
    //
    p    = max(1,min(999,p))     //1 - 999
    M1   = max(1,min(999,M1))    //1 - 999
    M2   = max(1,min(999,M2))    //1 - 999
    M3   = max(1,min(999,M3))    //1 - 999
    Type = max(0,min(8,Type))    //0 - 8
    //
    x    = close - close[1]
    Su   = summation[p](x * (x > 0))
    Sd   = summation[p](abs(x) * (x < 0))
    CMO  = ((Su - Sd) / (Su + Sd)) * 100
    //----------------------------------
    //        alternative code:
    //IF BarIndex = 0 THEN
    //   SumUP = 0
    //   SumDN = 0
    //ENDIF
    //SumUP = abs(max(close - close[1],0))
    //SumDN = abs(min(close - close[1],0))
    //Su    = summation[p](SumUP)
    //Sd    = summation[p](SumDN)
    //CMO = 100 * ((Su - Sd) / (Su + Sd))
    ////----------------------------------
    ma1  = Average[M1,Type](CMO)
    ma2  = Average[M2,Type](CMO)
    ma3  = Average[M3,Type](CMO)
    RETURN CMO as "Chande Momentum Oscillator",ma1 AS "ma1",ma2 AS "ma2",ma3 AS "ma3"

    You can easily set the colours and the style of your choice via the indicator’s settings.

    Mary thanked this post
    Chande-Momentum-Osc.-CMO-MMA.itf
Viewing 2 posts - 1 through 2 (of 2 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

This particular Chande’s Momentum Oscilator MMA


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Mary @mila Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
4 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/07/2022
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...