You assume history is ordered by date, it's not. Could EA Really Live
By Order_History Alone? (ubzen) - MQL4 forum
honest_knave:
if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY))
You are always checking the order with index 0 in the history pool.
You'll want to loop through all the order history and find the most recent one to check. Have a search and you'll find lots of information on this.
Hi honest_Knave
I managed to solve my problem.
Thank you
whroeder1:
You assume history is ordered by date, it's not. Could EA Really Live By Order_History Alone? (ubzen) - MQL4 forum
Thank you for the reply, I have checked out the link you mentioned and its very helpful, thanks.
You assume history is ordered by date, it's not. Could EA Really Live By Order_History Alone? (ubzen) - MQL4 forum

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
Hi Guys,
I have just started using mql4. I was trying a simple algorithm for which I needed to check if the previous order was a stoploss. I searched around the documentation and found the OrderSelect method to do this and I coded the following code. My issue was that when I tested this method on the backtest it would never change the state of either buyIgnore or sellIgnore to true even though the previous order did hit stoploss.
Please help me out guys.
Thanks.