int Hist=OrdersHistoryTotal();// OrdersHistoryTotal()-1 if(OrderCloseTime()!=0) // how can be OrderCloseTime() not equal to something in History OrderOpenPrice()-OrderClosePrice() > 80 // my guess is OrderOpenPrice()-OrderClosePrice() > 80*Point
qjol:
datetime OrderCloseTime( | ) |
Note: The order must be previously selected by the OrderSelect() function.
Sample:
if(OrderSelect(10,SELECT_BY_POS,MODE_HISTORY)==true) { datetime ctm=OrderOpenTime(); if(ctm>0) Print("Open time for the order 10 ", ctm); ctm=OrderCloseTime(); if(ctm>0) Print("Close time for the order 10 ", ctm); } else Print("OrderSelect failed error code is",GetLastError());
qjol:
OrderOpenPrice()-OrderClosePrice() > 80 // my guess is OrderOpenPrice()-OrderClosePrice() > 80*PointYes it is. thanks
richo:
I am trying to find whether the last order closed is by Stop-loss or not
I am trying to find whether the last order closed is by Stop-loss or not
for(int iPos= OrdersHistoryTotal() - 1; iPos >= 0; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() // and my pair. && OrderType() <= OP_SELL // Avoid cr/bal https://www.mql5.com/en/forum/126192 ){ if( MathAbs(OrderClosePrice() - OrderTakeProfit()) > MathAbs(OrderClosePrice() - OrderStopLoss() ){ // Closed by SL } else{ // Closed by TP } break; // Last closed only }
WHRoeder:
x
x
Thank you so much. very helpful.

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 am trying to find whether the last order closed is by Stop-loss or not.
My fixed stop-loss is 100 pips, so I call order history and check the OrderClosePrice() > (100-10)
Please correct me.