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?
double OCP = OrderClosePrice();
bool isSL = MathAbs( OCP - OrderStopLoss() ) < MathAbs( OCP - OrderTakeProfit() );