Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Millions of traders are waiting for this!
Pavel Soukup
559
Pavel Soukup 2014.11.03 12:03 

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
13613
whroeder1 2014.11.03 14:56  
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