Download MetaTrader 5

How precisely identify close positon on target (SL)

To add comments, please log in or register
Pavel Soukup
560
Pavel Soukup  

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. 

whroeder1
15326
whroeder1  
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() );
To add comments, please log in or register