Download MetaTrader 5

Last Order type and closing type

To add comments, please log in or register
Egils
5
Egils  

Hello!


I need help with my expert advisor.

I want to detect wether previos trade was stoped out by stop loss and what was the opening type (BUY or SELL) of previous order.

I need this becaus i don't want to open new trade immidiatly after previous trade was stoped by sl.


thanx

Simon Gniadkowski
Moderator
18025
Simon Gniadkowski  
LatvianFX:

Hello!


I need help with my expert advisor.

I want to detect wether previos trade was stoped out by stop loss and what was the opening type (BUY or SELL) of previous order.

I need this becaus i don't want to open new trade immidiatly after previous trade was stoped by sl.

Loop through the trades in the history, select them one by one, check their OrderCloseTime() to find the most recent, once you have the most recent find it's type using Ordertype() and then check it's OrderClosePrice() and compare it against it's OrderStopLoss() to try and determine it was closed by SL.
To add comments, please log in or register