How precisely identify close positon on target (SL)

 

Hi quys,

I think.... how precisely identify close position on target price, or stop loss price.

Because condition as OrderClosePrice()==OrderOpenPrice()+OrderTakeProfit() (for long) isn´t reliable code for very quickly market or gap... 

 I don´t know that OrderComment() by closed order is the same all brokers or no.

Example: My broker have comment "tp" for positon ended on target price ans comment "sl" for positin which finish on stop loss. But does have it all brokers? 

Or other idea?

Thank you. 

 
endy5:
Because condition as OrderClosePrice()==OrderOpenPrice()+OrderTakeProfit() (for long) isn´t reliable code for very quickly market or gap...
Example: My broker have comment "tp" for positon ended on target price ans comment "sl" for positin which finish on stop loss. But does have it all brokers?
  1. Price plus a price is meaningless. OrderTakeProfit() is not an offset.
  2. Isn't reliable because SL/TP are stops - they become market orders when triggered - price will never be reliably exact.
  3. Isn't reliable because price is a float - The == operand. - MQL4 forum
  4. Most broker's don't.
double  OCP  = OrderClosePrice();
bool    isSL = MathAbs( OCP - OrderStopLoss() ) < MathAbs( OCP - OrderTakeProfit() );
Reason: