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]
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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?