Can't find how to Return the OrderClose Boolean. Need to load OrderClose event into array

 

Hi ,

I'm trying to return the parameters from the OrderClose function event.  I want to load it into an array as each one occurs.

Example: When a Take Profit or StopLoss is hit, the order is closed . I want know When and at what price it closed, as it occurs.  The problem I'm having is that the order is sent ahead of time,pending,, as opposed to if I would Close the Order with the OrderClose() Function.

Can't find documentation on how to return the OrderClose info on the same tick or bar that it occurs on. All I see  documented is how to Close the order, using OrderClose().

I need to distinguish those orders which closed by TakeProfit or StopLoss, from those that closed using the OrderClose() function in the code. 

Thanks

John 

 
researchpro: I need to distinguish those orders which closed by TakeProfit or StopLoss, from those that closed using the OrderClose() function in the code.
  1. There is none. Either you must remember it, or:
  2. I normally use:
    double OCP = OrderClosePrice();
    double OTP = OrderTakeProfit();
    double OSL = OrderStopLoss();
    bool wasSL = MathAbs(OCP - OSL ) < MathAbs(OCP - OTP );
    If the diistance between OCP and SL/TP is larger than (say) 10 pips, just close.
    Otherwise modify the order, move the SL/TP beyond 10 pips before closing. Then you can test
    double OCP = OrderClosePrice();
    double OTP = OrderTakeProfit();
    double OSL = OrderStopLoss();
    double dSL = MathAbs(OCP - OSL );
    double dTP = MathAbs(OCP - OTP );
    
    bool wasSL = dSL < dTP && dSL < 10 * pips2dbl;
 
WHRoeder:
researchpro: I need to distinguish those orders which closed by TakeProfit or StopLoss, from those that closed using the OrderClose() function in the code.
  1. There is none. Either you must remember it, or:
  2. I normally use:If the diistance between OCP and SL/TP is larger than (say) 10 pips, just close.
    Otherwise modify the order, move the SL/TP beyond 10 pips before closing. Then you can test

Excellent WHRoeder. Thank you for your help.

Using Less Than, will allow a fuzzy conclusion to create the bool I need to distinguish Types -- without having to meet an exact predetermined price criteria.

John 

Reason: