Trailing at the iLowest iOpen of the previous 45 bars
2021.12.11 21:21:32.876 2021.06.01 02:23:45 TSL: 0.77388
2021.12.11 21:21:33.386 2021.06.01 02:23:45 45 bars TSL: 0.77406
2021.12.11 21:21:33.386 2021.06.01 02:23:45 position modified [#2 buy 0.3 AUDUSD 0.77439 sl: 0.77406 tp: 0.77623]
I am trying to trail with a Stop loss at the lowest open of the last 45 1 minute candles.
This is what my code looks like:
My 2 printfs return the following:
2021.12.11 19:44:35.427 2021.06.01 02:23:45 TSL: 0.77388
2021.12.11 19:44:35.974 2021.06.01 02:23:45 45 bars TSL: 0.77437
2021.12.11 19:44:35.974 2021.06.01 02:23:45 position modified [#2 buy 0.3 AUDUSD 0.77439 sl: 0.77437 tp: 0.77623]
The iOpen does not return the correct value, as shown on my printf "45 bars TSL"
It then modifies the Stoploss to highest of the two values, which is what I intended IF the calculation had gone correctly.
I believe I made a mistake on this potion of code but I can't see the error. Can someone point me in the right direction?