I want a event that trigger always when a position is closed by SLTP. I found nothing native from MQL5 to do it, so I'm trying approaches to do myself an OnSLTP() function.
A piece from my code to do it uses the history:
I notice that if I use this sequence, the data will be returned right:
But if I invert the 2nd and 3nd lines, the orderType info will be wrong after some iterations.
Someone knows why this happen? I think that HistoryOrderGetDouble is setting some global reference that change the HistoryOrderGetInteger behavior...
Please provide data and output log to demonstrate what you mean, as it doesn't make sense.
You NEED to check the returned value of functions : HistorySelect(), HistoryOrderSelect().

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want a event that trigger always when a position is closed by SLTP. I found nothing native from MQL5 to do it, so I'm trying approaches to do myself an OnSLTP() function.
A piece from my code to do it uses the history:
I notice that if I use this sequence, the data will be returned right:
But if I invert the 2nd and 3nd lines, the orderType info will be wrong after some iterations.
Someone knows why this happen? I think that HistoryOrderGetDouble is setting some global reference that change the HistoryOrderGetInteger behavior...