PPO

Hi,

I’m having difficulty getting the PPO Negative Divergence to work. The PPO red vertical line should be over the arrows where it applies in the attached chart. It is also producing a very thick red vertical line which I cannot explain.

Can someone please let me know what I’m doing wrong.

Thanks,

Karen

OptumaSent-08.08.2020.owb (22.8 KB)

Hi Karen,

Sorry, but after “playing” with your script for a while I’ve not come up with a solution to your issue☹ Only more unknowns/inexplicables☹

In the attached workbook you’ll find a View - Plot V1, V2, Sig 1, Sig 2, Sig3, P1, PPOPlot1 in which I’ve modified your script a little, but mainly by adding plots for each of the variables, which is the method I use for trying to work out what is going on within the script. These plots are shown in the bottom view in the attached workbook. Some of the plots are commented OFF, so to see their results just remove the “//” comment tags, and apply others as the plot vertical scales differ vastly.

In particular, regarding the changes I’ve made, you’ll notice in the script that where you’re making comparisons I’ve converted the code to IF statements, this ensures you get clear boolean True/False, ie 1/0, result to the tests. Also your P1<>0 have been changed to P1>0 because your P1 calculation should only produce results greater than zero.

I plotted most of the variables in your scripts and for some reason that I come up with the following anomalous results:

  • The plot (Black) of "PPOPlot1 = ((PPOMA1 - PPOMA2) / PPOMA2)*100;" looks nothing like the plot of "Plot1 = ((MA1 - MA2) / MA2)*100;" in your original PPO Indicator (Green) script☹ You'll need to un-comment this plot to see it.
  • My "P1 = PIVOT(PPOPlot1, MIN=15, TYPE=High, DIR=Both);" (cyan) is nothing like your "Show Bar Pivot 15 Hi (on PPO Indicator 5 / 60 / 5)" (red). My cyan plot shows many P1>0 where there is no Pivot Hi 15 (red arrow) on your plot☹
  • When Sig1 and Sig2 both equal, so Sig3 (Orange) is true (=1) in my script they don't produce the red signals you are displaying☹
There are other confusing results as well, but I'm betting you'll, and whoever else tries to solve this, gets the idea.

Quite frankly, the whole thing has me bamboozled☹

I just hope brighter spark than me (shouldn’t too hard to find) can resolve the issues for you, and me.

Good luck with it…

Trevor

20200808-TRB-Karen-PPO-OptumaSent-08.08.2020.owb (50 KB)

Hi Karen,

Can you please paste the actual script in here. I prefer not to open workbooks and to go looking for the script in question. Remember to use the “<> Code” button in the toolbar here in the forum. It ensures that the scripts can be copied and pasted without the editor changing characters.

All the best

Mathew


Hi Mathew,

The script is copied below. Also is there any update as to timing on the support and resistance lines automated tool being developed - I was just wondering the timing of its availability.

Thanks again,

Karen

<hr />

 

//Negative PPO divergence
// Calculating PPO
PPOMA1 = MA(BARS=5, STYLE=Exponential, CALC=Close);
PPOMA2 = MA(BARS=60, STYLE=Exponential, CALC=Close);
PPOPlot1 = ((PPOMA1 - PPOMA2) / PPOMA2)*100;
//PPOPlot2 = MA(PPOPlot1, BARS=5, STYLE=Exponential);

//calculate 15 pivot PPO high
P1 = PIVOT(PPOPlot1, MIN=15, TYPE=High);

//get value of the PPO peak
V1 = VALUEWHEN(PPOPlot1, P1 <> 0);

//Is PPO high < previous?
Sig1 = V1 < V1[1]*0.96;

//get stock high value at PPO peak
V2 = VALUEWHEN(HIGH(), P1 <> 0);

//Is stock high higher than at previous PPO peak?
Sig2 = V2 > V2[1]*1.04;

//Show when PPO has lower high & price higher low
Sig1 and Sig2

Hi Karen

The new tool is in Support Resistance Finder in Optuma 1.6 (KB here https://help.optuma.com/kb/faq.php?id=1187)

SRF

I’ll have a look at the script this afternoon.

All the best

Mathew

 


Hi Mathew,

I’m also using the following to pinpoint the highs and lows of the PPO. I would have thought that the vertical line if there is negative divergence would have to be on the same day.

//Show Bar PPO High

PIVOT(MIN=15, TYPE=High)>1

//Show Bar PPO Low

PIVOT(MIN=15, TYPE=Low)<-1

Thanks,

Karen

 

Hi Karen,

I’m assuming—by looking at your script—that negative divergence is when the PPO indicator is going down and the price is going up. My comments below are based on that assumption. If you are looking for something else, please let me know where I can read the theory behind it. I agree with Trevor that the best way to approach any issue is to output each line and check that it is what you expect.

Comment 1 - Pivot should be backwards-looking only.

P1 = PIVOT(PPOPlot1, MIN=15, TYPE=High, DIR=Backwards);

We pass through the data in order and if we consider both directions then we are adding in a forward-looking bias.

Comment 2 - ValueWhen() holds the value until the condition is next true. Here is the value of V1. In this image the lines are your event of

P1 <> 0

and the shaded area is

V1 = VALUEWHEN(PPOPlot1, P1 <> 0);

Note how the level stays until the next time P1 <> 0.

ppo1

This means that the following line is actually looking for a decrease in the value of the PPO when the signals happened

//Is PPO high < previous?
Sig1 = V1 < V1[1]*0.96;

I don’t think that is what you are looking for. The actual solution to this is not trivial and is beyond what I can do here right now. If you want us to solve this, we’d need you to organise a Scripting consult at optuma.com/consults

An alternative is to use the Vergence function. (See KB https://help.optuma.com/kb/faq.php?id=960)

//Negative PPO divergence
// Calculating PPO
PPOMA1 = MA(BARS=5, STYLE=Exponential, CALC=Close);
PPOMA2 = MA(BARS=60, STYLE=Exponential, CALC=Close);
PPOPlot1 = ((PPOMA1 - PPOMA2) / PPOMA2)*100;

VERGENCE(High(), PPOPlot1, TYPE=Divergence)

All the best

Mathew

Hi Mathew,

I have tried the Vergence code and it’s not what I’m after.

What I’m trying to do is to look for the high or low in the PPO pivots and mark it with a show bar arrow. I have been able to do this easily enough so I can see where the highs and lows are in the PPO indicator.

It is the next step that is not working: Next I am trying to then determine for eg where each arrow of a high PPO occurs what the corresponding high in price for that bar would be. Then, I’m trying to compare for eg the last 2 PPO pivot high arrows so that if the last PPO high pivot value (PPOV) is lower than the previous PPO high pivot value (PPOV[1]) and the corresponding high prices ie High(Price) is higher than High(Price[1]) then it will trigger a vertical line as negative divergence on the last PPO high pivot value (PPOV). It will also be the opposite as well ie the last PPO pivot value (PPOV) is higher than the previous PPO pivot value (PPOV[1]) and the corresponding high prices High(Price) is lower than High(Price[1]). I will then look to do the equivalent coding for positive divergence.

I have been able to get this to work for the RSI indicator quite simply which looks like the screen shot attached. I am just trying to setup the equivalent in the PPO indicator. I would be grateful if you could see if you could assist given the above description.

Thanks again and kind regards,

Karen

 

 

Hi Karen,

It should work the same way as for RSI, so maybe reduce the 4% tolerance for sig1 and sig2 (eg sig1 * 0.98 and sig2 * 1.02) and see if that helps.

Hi Darren,

I have tried your suggestion and it doesn’t work and I have used a very similar formula that I used for the RSI divergence. I have spent hours on this and would greatly appreciate it if you could have a look at the code attached. If there is divergence it should place the vertical line over the relevant arrow which in many cases it does but some cases it does not. I also cannot explain the thick red line in some instances. I look forward to your comments.

Thanks,

Karen

Hi Karen,

I thought it was because you were using a Show Plot instead of a Show Bar for the signal:

Capture

But even when I deleted the Show Plot and reapplied the formula using a Show Bar it didn’t show the correct divergences. The only way I could get it to work was to apply the formula in a Show View which then showed them correctly, which could then be dragged over the PPO:

Capture

Thanks Darren.