Icham Aidibe:
Hi,
I'd like to know when a deal is closed by hitting a SL how to detect it ? By browsing the history I can know if the deal has been closed or not, but how to read the way the deal is closed (sl hit) ?
In my opinion:
if(OrderClosePrice() == OrderStopLoss())
3rjfx:
Yep. Thanks.
In my opinion:
3rjfx:
Will not work on a real account, most of the time.
In my opinion:
How to detect order close by stoploss? - MQL4 forum
- www.mql5.com
How to detect order close by stoploss? - MQL4 forum
bool LastClosedTrade(){ int cnt, total; total = OrdersHistoryTotal(); for(cnt=0;cnt<total; cnt++){ OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderClosePrice()==OrderStopLoss()){ return(true); } } return(false); }But you must put many things into considerations, like case of OP_BUY and OP_SELL order types and if price went more points that it should be "< and >", ... , ...
Icham Aidibe:
Hi,
I'd like to know when a deal is closed by hitting a SL how to detect it ? By browsing the history I can know if the deal has been closed or not, but how to read the way the deal is closed (sl hit) ?
//-------------------------------- ES CIERRE POR SL ---------------------------------------------- bool esCierreSL(int ind, int modoInd= SELECT_BY_TICKET) { bool resp= OrderSelect(ind, modoInd, MODE_HISTORY)? (StringFind(OrderComment(), "[sl]", 0)>-1): false; return(resp); }
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,
I'd like to know when a deal is closed by hitting a SL how to detect it ? By browsing the history I can know if the deal has been closed or not, but how to read the way the deal is closed (sl hit) ?