I have been using Darren’s breakout pivot script to identify potential areas of support:
//Define the pivot criteria
V1=PIVOT(MIN=15, TYPE=Low);
//Get the current high price and when the last V1 pivot occurred
L1=LOW();
V2=VALUEWHEN(LOW(), V1);
//Calc 1% rule
WITHINRANGE(V2,L1,PERCENT=1.00)
When I backtested a buy within 1% of a prior low - I found the backtest cheating and taking trades on the day a new pivot formed as opposed to an existing pivot (at that time).
What’s a possible way to test this style of pivot support?
This is a known issue when using the PIVOT function in testing because the labels can change depending on new data coming in to the chart. As such, pivot scripts should only be used to display on the chart, and not for testing.
Instead you could use values of swing lows instead of pivots using something like this, but I haven’t tried it in testing:
//Define swing criteria
GS1 = GANNSWING(SWINGCOUNT=2, METHOD=Use Next Bar, USEINSIDE=True);
V1 = SWINGSTART(GS1);
//Get the current low price
L1=LOW();
//Is it within 1% of the most recent swing low?
(L1/V1 > 1) and (L1/V1 < 1.01)
In Optuma 2 the Pivot() function has an option to ignore unconfirmed pivots, so only those that won’t change when new data comes in are included in the criteria.
In this example you can see the Show Bar tool ignores the last pivot label (light grey) as it is currently unconfirmed:
This is for current data only, historical data still has an issue that it knows a pivot is there, before it is actually confirmed.
Pivots still shouldn’t be used for backtesting because of this, not without adding in some extra code to not take a pivot into account until x bars after a pivot label (TimeSinceSignal() for example).