Percentage Price Oscillator (PPO)

v10.3
Percentage Price Oscillator (PPO)

The percentage price oscillator (PPO) is a technical momentum indicator that shows the relationship between two moving averages. To calculate the PPO, subtract the 26-period exponential moving average (EMA) from the 12-period EMA, and then divide this difference by the 26-period EMA. The result is then multiplied by 100. The indicator tells the trader where the short-term average is relative to the longer-term average.

 

I am also attaching the MACD type version (it is very similar):

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. juanj • 12/07/2018 #

    Haven’t been on this forum for ages! Just logged in to see what is happening and since this caught my eye I decided to quickly write it into a strategy 🙂

    For some reason, the Add PRT Code doesn’t work so here is the unformatted code:

    //EURUSD 1Hr

    Defparam cumulateorders = False

    possize = 1
    SlowP = 26 //Periods of Slow Average
    FastP = 12 //Periods of Fast Average
    AvgType = 1 //Average Type (0=sma, 1=ema, 2=wma,…)
    Percentage = 1 //1=calculate Percentage 0=no percentage
    SignalP = 9 //Periods of Signal Average
    //
    SlowP = max(1,min(999,SlowP)) //1 – 999
    FastP = max(1,min(999,FastP)) //1 – 999
    AvgType = max(0,min(6,AvgType)) //0 – 6
    Percentage = max(0,min(1,Percentage)) //1=Percentage 0=NO Percentage
    SignalP = max(1,min(999,FastP)) //1 – 999
    SlowAvg = Average[SlowP,AvgType](close)
    FastAvg = Average[FastP,AvgType](close)
    ppo = FastAvg – SlowAvg
    IF Percentage THEN
    ppo = (ppo / SlowAvg) * 100
    ENDIF
    SignalLine = Average[SignalP,AvgType](ppo)
    Histo = Ppo – SignalLine

    If longonmarket and histo < 0 or ppo 0 or ppo > SignalLine Then
    Exitshort at market
    EndIf

    If ppo > 0 and signalLine SignalLine Then
    If shortonmarket Then
    Exitshort at market
    EndIf
    Buy possize contract at market
    ElsIf ppo 0 and ppo < SignalLine Then
    If longonmarket Then
    Sell at market
    EndIf
    Sellshort possize contract at market
    EndIf

  2. robertogozzi • 12/07/2018 #

    Welcome back Juanji, why don’t you post your strategy in the ProOrder support, it’s a better place to talk about strategies and improve them.
    Thank you.

  3. SB-FO • 12/07/2018 #

    Nicolas, I am trying to replicate Price Oscillator of PRC (PO NOT PPO) using manual programing to make sure i have it correct. I thought I had it correct but a comparison backtest of the two has very different results. Can you please define the calculation for PRC PriceOscillator as i clearly have something wrong below and PRC does not specify the calculation.

    xClose = Close
    AvgType = Average // weightedAverage //ExponentialAverage //
    Fastp = A
    Slowp = B
    TriggerAve = C

    ShortAvg = Average[Fastp,AvgType](xClose)
    LongAvg = Average[Slowp,AvgType](xClose)
    PPO = ShortAvg – LongAvg

    PPO = PriceOscillator[A,B](Xclose)
    Trigger = Average[C](PPO)

    • robertogozzi • 12/07/2018 #

      Hi, I am not Nicolas.
      Where is the formula of the Oscillator you want to code?

    • robertogozzi • 12/07/2018 #

      It’s just the difference of two averages:
      PO = Fast Moving Average – Slow Moving Average

  4. SB-FO • 12/07/2018 #

    Robertogozzi, I agree with it being the difference of the two MA’s, however when i compare that to “PriceOscillator[A,B](Xclose)” in PRT it get different backrest results. Thus my question is, what is the code for “PriceOscillator[A,B](Xclose)” so that i can compare why the results are different.

    Thanks for your help.

    • robertogozzi • 12/07/2018 #

      Sorry, I can’t find any built-in PPO in PRT, so I cannot tell.

  5. SB-FO • 12/07/2018 #

    Look up Price Oscillator, that is the prebuilt in am referring to, PO not PPO.

    • robertogozzi • 12/07/2018 #

      I have plotted 4 similar indicators on mty chart: PPO, PO (built-in), MACD (built-in) and APO, all with a 12-period fast MA and a 26-period slow MA, all with the same type of moving average, EMA, applied to CLOSE.
      They all show the same result. It can’t be any different since it’s the same expression in all of them!
      The only difference can only be spotted when using different types of Moving Averages.
      If you still have issues I suggest that you start a new topic in the ProBuilder support so that we can attach pics.

  6. SB-FO • 12/07/2018 #

    Do you mind looking at my code to see if i ma doing something wrong?

    xClose = Close
    AvgType = Average
    Fastp = A
    Slowp = B

    ShortAvg = Average[Fastp,AvgType](xClose)
    LongAvg = Average[Slowp,AvgType](xClose)
    PO = ShortAvg – LongAvg

    When I code this, i get a different back test than using the standard PO from PRT.

    • robertogozzi • 12/07/2018 #

      AvgType = 1 //0 to 8, but is usually o=sma or 1=ema
      This is the only thing that may cause an error.

  7. SB-FO • 12/07/2018 #

    Ah ha. I will check that and report back. Thank you.

  8. SB-FO • 12/07/2018 #

    Robertogozzi,

    I have backtested the two following PriceOscillator code, which I thought would result in the same returns, alas they do not. Do you have any insights? I will say that using WeightedAverage is closer to the built in PriceOscillator, yet still not the same. Of course using the same parameters and time period. Do you have any insights as to why this would happen?

    ShortAvg = WeightedAverage[A] (Close)
    LongAvg = WeightedAverage[B] (Close)
    PO = ShortAvg – LongAvg

    PO = PriceOscillator[A,B](Close)
    Trigger = Average[C](PO)

  9. robertogozzi • 12/07/2018 #

    Please post the full working code, otherwiose I can’t replicate it.
    Tellme what you compared it to.

  10. SB-FO • 12/07/2018 #

    Code below. Comparison is to PRT standard PO which is // out.

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    DEFPARAM FLATBEFORE = 093000
    DEFPARAM FlatAfter = 154500
    capital = 100000 + strategyprofit
    Equity = capital / close
    myCurrentProfit = STRATEGYPROFIT

    ShortAvg = Average[22] (close)
    LongAvg = Average[7] (close)
    PO = (ShortAvg – LongAvg)

    //PO = PriceOscillator[22,7](Close)

    Trigger = Average[2](PO)

    // Draw indicator
    Graph PO COLOURED(34,139,3) AS “SBFO PO”
    Graph Trigger COLOURED(225,0,0) AS “Trigger”

    // Conditions to enter long positions

    IF NOT LongOnMarket AND PO Crosses Over Trigger THEN
    BUY Equity SHARES AT MARKET
    ENDIF

    // Conditions to exit long positions
    If LongOnMarket AND PO Crosses Under Trigger THEN
    SELL AT MARKET
    ENDIF
    //
    //Conditions to enter short positions
    IF NOT ShortOnMarket AND PO Crosses Under Trigger THEN
    Sellshort Equity SHARES AT MARKET
    ENDIF

  11. robertogozzi • 12/07/2018 #

    Firstly you need to make the correct calculation, you need to swap 22 and 7.
    Secondly PRT’s POI uses to return a percentage, so you need to replace the calculation with:
    PO = (ShortAvg – LongAvg) / LongAvg * 100

  12. SB-FO • 12/07/2018 #

    Sorry, i did forget to change the 7/22, I have run it both ways.
    PRT is calculating PPO and not PO, that make sense now.

    Thanks. Have a fantastic weekend.

  13. RubberToe • 12/07/2018 #

    I believe there is an error in line 23 of the MACD version. It points to the FastP. Should be SignalP I think….

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Vicari0us Really liking this indicator. Thanks
SB-FO Moving your last response to this post. Thanks for conforming the code below. How does PRT/...
Nicolas It is obtained by substracting the x days before Close from today’s Close. X is the paramete...

Top