Using Pivot(), but Not Working with Other Signals

Hi All,

I have a script intended to identify a potential Short Entry following an Outside Bar with a Low Close at a Pivot that is followed by a Down Bar. Here is my script:

// High Pivot Outside Bar Low Close Short Entry

PivotSignal = PIVOT(MIN=11, TYPE=High);

OutsideSignal = (HIGH(0) > HIGH(1)) and (Low(0) < Low(1)) and (CLOSE(0) < (Low(0) + (High(0) - Low(0)) / 3));

EntrySignal = (LOW(-1) < LOW(0)) and (High(-1) < High(0));

PivotSignal and OutsideSignal and EntrySignal

When I test each “***Signal” separately as a SHOWBAR they will identify the desired signal, as does “OutsideSignal and EntrySignal”, but as soon as I try “PivotSignal and OutsideSignal and EntrySignal” no SHOWBAR is displayed.

In the following screenshot the Diamond is above a bar that meets all criteria, but there is no SHOWBAR present:

20190616  High Pivot Outside Bar Low Close Short Entry

What am I missing here? Is there something in the way the Pivot() function works that is preventing the combined signals from being registered? How to overcome this issue?

Cheers

Trevor

 

Hi All,

Standing under the shower I had a bright idea and so I changed my PivotSignal code to:

PivotSignal = if(PIVOT(MIN=11, TYPE=High), 1, 0);

Now "PivotSignal and OutsideSignal and EntrySignal" works as intended.

But, I still don’t understand why. My understanding is that “PIVOT(MIN=11, TYPE=High)” returns “1” which I’d have expected would work, but it seems that is not so. Any explanation as to why will be appreciated.

Cheers

Trevor

 

Hi Trevor,

PIVOT(MIN=11, TYPE=High)

This line doesn’t return a Boolean result, it returns values grater than zero based on the bar count between pivots. If you apply it to the chart using a Show View you can see what it’s doing:

ex1

By wrapping the IF() function around the PIVOT() line, you changed the result to a true Boolean which allowed the rest to work as expected.

Many thanks Matthew.

Hi Matt,

In your chart of ASX above, how to script the difference between two Pivot Labels, say (201 - 25) bars as the offset period is a variable? My below script does not work:

V1 = PIVOT(MIN=10, TYPE=High, DIR=Backwards);

V3 = TIMESINCESIGNAL(V1);

V1 - V1[V3]

Hi May,

To show the time between each pivot use the following:

V1=PIVOT(MIN=11, TYPE=High);
TIMESINCESIGNAL(V1>=11)

So there were 27 trading days between H25 and H201 in the example (displayed in a Show View, set to dots). Is that what you are trying to do?

Capture

Hi Darren,

Thanks for comment. But no.

What I want is to compare the value of two Pivot Labels. i.e. I want to script for (201 - 25) = 176 bars, (25-16) = 9 bars, and so on so forth. Then I can do show view or scan to find when there is a jump to indicate that particular Pivot Label is a significant level breakout over time.

 

Hi May,

To do this you need to use a few functions: Pivots, NONZero and IF. In the example below I’ve included some comment lines showing what each line is doing:

//Set Pivot Value - High Only - Remove Zeros
V1 = NONZERO(PIVOT(MIN=12, TYPE=High));
//Set Previous Bars Pivot Value
V2 = V1[1];
//Set Current Pivot Value - Previous Bars Pivot Value
V3 = V1 - V2 ;
//When Pivot Value changes find the difference
IF(V1 <> V2,V3,0)

You can see how the above script looks when applied to a Show View:

Ex1

Got it. Many thanks to Matt and Darren!

Re: Quote#53705 above

In the ASX chart, is it possible to compare non-adjacent pivots? I want to know whether there are 3 pivots that each is higher than the previous one. in chronological order.

e.g. 201 is higher than 53 and 53 is higher than 18. 201 is also higher than 16 and 16 is higher than 12.

As 201 is the current pivot and I want to look backward, SIGNALAFTER() cannot be applied.

Hi May,

The following script is an example of how you can find 3 higher pivot labels in a row:

//Set Pivot Label Settings and use High only
PV = PIVOT(TYPE=High);
//Remove Non Zero values
PVList = NONZERO(PV);
//Identify 3 Consec Higher Values
PVList > PVList[1] and PVList[1] > PVList[2]

However, this does not work on the examples mentioned when those values are not in consecutive order. The two examples mentioned cannot be identified by this script. So is there a function that can rank the values first and then by chronological order?

Hi May,

If you can provide a screen shot example(s) of the setup you’re trying to identify it will be easier to see if a scripting solution is possible or not.

As attached screenshot, I am trying to identify a Wedge Up pattern. Show View shows the price difference between the Pivot High and Pivot Low. I want to identify if the price difference of any 3 bars in Show view are decreasing in value. The first 3 bars in May-Jul can be identified by the Script you mentioned because they are consecutive in a row. But the 3 bars Bar 4,5,7 also qualified.

So I need to sort the bars by date (can use BARDATE() to identify the date of Pivot High), and see how many groups of 3 bars that match the criteria?

If look back period = 6 months, there are 4 bars, Bar 4 - 7. Bar 4,5,7 is the group that match.

If look back period = 1 year, there are 7 bars in total, Bar 1-7. There are 4 groups that match.

group 1 = Bar 1, 6, 7

group 2 = Bar 4,5,7

group 3 = Bar 1,4,7

group 4 = Bar 1,5,7

Kindly advise.

 

Capture

As attached screenshot, I am trying to identify a Wedge Up pattern. Show View shows the price difference between the Pivot High and Pivot Low. I want to identify if the price difference of any 3 bars in Show view are decreasing in value. The first 3 bars in May-Jul can be identified by the Script you mentioned because they are consecutive in a row. But the 3 bars Bar 4,5,7 also qualified.

So I need to sort the bars by date (can use BARDATE() to identify the date of Pivot High), and see how many groups of 3 bars that match the criteria?

If look back period = 6 months, there are 4 bars, Bar 4 - 7. Bar 4,5,7 is the group that match.

If look back period = 1 year, there are 7 bars in total, Bar 1-7. There are 4 groups that match.

group 1 = Bar 1, 6, 7

group 2 = Bar 4,5,7

group 3 = Bar 1,4,7

group 4 = Bar 1,5,7

Kindly advise.

 

Capture