fix bug on a small library that detect pivots

Job ID: 39310161

Budget: $30 – $250 CAD

Hello,

i have a small library (170 lines) that detect pivot with a simple logic.
It's almost perfect but i still have a last bug that i can't figure out.

Bug : Some pivots are created where they shouldn't. See screenshots for exemples (with dates and instrument).

Logs are already set on the library and working.

i joint the code source of the library and a script to display pivot from this lib for testing.


Here is the logic :

- pivots are 3 bars fractals :
pivot high = high3 <= high2 > high1
pivot low = low3 >= low2 < low1
Logic already implemented, all good.

- When two consécutive same side pivot appears (exemple : 2 pivot high in a row), the script create an oppposite fractals (hidden pivot) at the lowest point between these two high. (oppposite logic for 2 consécutive low.)
Logic already implemented, likely good.

- Double pivot logic (pivot high and low on the same bar) : Check lower timeframe for first pivot creation, then the normal script logic apply. (this is function copy from this : https://www.tradingview.com/script/lRY74dha-Absolute-ZigZag-Lib/).
Logic already implemented, probably bugging.

I am available if you have any questions ,
thanks
Related categories: Pine Script Trading