Close an Open Oder before the TakeProfit limit is reach

 

Dear

 

I’m new on MT4.

I’ve been trying for many days to Close an open Order (which has been set up with a take profit limit), before the TakeProfit limit is reach.

 

My initial command is :

  

OrderSend(Symbol(), OP_SELL ,Lots ,Bid ,3 ,0 , Bid-TakeProfit*Point, NULL ,16384,0,Red);

 

I have a Close condition for example :

 

If ( ( SignalPrevious > 0 ) && (SignalCurrent < 0) )

{

   ….

OrderClose(OrderTicket(), OrderLots(), Ask , 3 ,Violet );

   ….

}

 

Even when I use : OrderSelect()  before OrderTicket(), OrderLots() , the close condition above is not taken into account ; the order run until the TakeProfit limit .

 

Could someone help me.

Thank in advance

Best regards

 
Dzwehao:


Even when I use : OrderSelect()  before OrderTicket(), OrderLots() , the close condition above is not taken into account ; the order run until the TakeProfit limit .


You MUST use OrderSelect() before using OrderTicket(), OrderLots()  etc . . . read the documentation . . .  "Note: The order must be previously selected by the OrderSelect() function."

What error does your OrderClose() generate ?  you are checking aren't you ?
 

Thank very much for your answer.

Actually, since I was not able to do it correctly, I was not sure if it was possible to Close the Order before it reach its Takeprofit limit.

I started back from the "MACD sample" and I deleted not usefull information; I've setup my one condition => it works well.

For now don't understand why it didn't work at first, since I tought I was applying the right rules, I still have to work deeper on that.

Thank again.

Reason: