Pivot show plot

Hi all

I have a tricky issue that I am struggling to find a way around, hoping someone can point me in the right direction.

I would like to have a show plot identify the ‘most recent’ low that occurs before a 3-bar ‘pivot’ high. The value that I am trying to identify must also be less than the low of the highest bar in the ‘pivot’ pattern. I have drawn a terrible diagram that hopefully explains what I’m trying to do. Worth noting, I don’t mean the Pivot labels tool (to my knowledge this finds slightly larger patterns that what I’m doing here).

This script was the best I could do, and it works as long as we get a ‘perfect’ pivot. However, the trailing nature of the LowestLow tool means that occasionally it moves on prematurely if there are additional bars within the pattern. Setting it to insidebar=false helps a little with this but not entirely. So I guess I need some kind of condition so that it ratchets up to the significant low and stays there until the next pivot high forms.

//define pivot high 
x1 = HIGH() > HIGH(OFFSET=1) and HIGH() > HIGH(OFFSET=-1); 
//find candle lows 
y1 = LOWESTLOW(BARS=1, INSIDEBAR=False, INCBAR=False); 
//find the final low prior to the pivot 
plot1 = VALUEWHEN(y1, x1);

Any suggestions hugely appreciated

Jonathan

Hi,

Using your code to identify the pivot, you could use the following to plot the previous bars low:

x1 = HIGH() > HIGH(OFFSET=1) and HIGH() > HIGH(OFFSET=-1);
x2 = IF(x1==1,Low(1),0) ;
NONZERO(x2)

This only changes when the next pivot is identified.

Ex8

Hi Matthew - thanks for the suggestion, I hadn’t thought of using an IF function.

However, there is still one issue (I probably haven’t explained it clearly enough, sorry). I need the show plot value to be lower in price than the low of the pivot bar, as well as to be before it.

So, in the above example, I need the show plot to rest at bar number 1 (reading from left to right) then to move down to the red bar 6.

Can you think of a way to get it to do that? I’ve tried so many things, including specifying endless unique candle patterns, using lowestlow(), and rethinking how the pivot is identified.

Thanks again
Jonathan

Hi,

I don’t think that can be done in scripting currently. However, my understanding is this could be done with the Pascal programming module (if you have access to that module).