Partial OrderClose()

 

Hi guys,

In MQL4, how can i use OrderClose() for partial close? 

I use this code:

ticket = OrderClose(OrderTicket(), lots/2, Bid, Ask - Bid, NULL);

but doesn't work.

Can you do an example for me, please


Thanks.

Marco.

 
  1. Why did you post your coding question in the MT5 Systems section instead of the MT5 General section, MT5 EA section, MT5 Indicators section, or MQL4 section?
              Moderators requested to manage this section. - Trading Systems - MQL5 programming forum 2020.05.25
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. See my code.

    1. You can't just use OrderLots()/2 because that is not a multiple of LotStep, and you can't close or have remaining less than MinLot.

    2. You also must check if you have already done it, to avoid repeated closing. Alternatives:

      • Move SL to Break Even+1 before the partial close. That way you know that you already did it.

      • Set a flag in persistent storage (files, global variables w/flush)

      • Open two orders initially, and close one (manually or by TP.)

  3. You can not use any Trade Functions until you first select an order.

 
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
William Roeder:
  1. Why did you post your coding question in the MT5 Systems section instead of the MT5 General section, MT5 EA section, MT5 Indicators section, or MQL4 section?
              Moderators requested to manage this section. - Trading Systems - MQL5 programming forum 2020.05.25
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. See my code.

    1. You can't just use OrderLots()/2 because that is not a multiple of LotStep, and you can't close or have remaining less than MinLot.

    2. You also must check if you have already done it, to avoid repeated closing. Alternatives:

      • Move SL to Break Even+1 before the partial close. That way you know that you already did it.

      • Set a flag in persistent storage (files, global variables w/flush)

      • Open two orders initially, and close one (manually or by TP.)

  3. You can not use any Trade Functions until you first select an order.

Sorry for post a wrong place.

I see your code, but I don't find what I look for the partial close. Can I have an example, please?