Partially close trades in TMF

Posted By: NorbertSz

Partially close trades in TMF - 11/06/23 15:16

Hello,

I want to close half of the trade at a certain price. I tried to accomplish that with a trade management function; when the conditions are met, I tried modifying the TradeLots, and also tried
Code
exitTrade(ThisTrade, 0, TradeLots/2);

but neither worked for me. I am aware of the following documentation comment...
Quote
TMFs can open new trades with enterLong/Short. However be careful when assigning them the same TMF: mistakes in entry conditions can lead to an endless loop of entering new trades. Exit a trade by returning 1, rather than calling exitTrade.

... but if I return 1, the whole trade closes. Do you have any idea?
Posted By: NorbertSz

Re: Partially close trades in TMF - 11/06/23 16:39

Ouch.

Quote
Trade size given by an integer number of lots (default = 1; max = LotLimit). [...] Since it's the minimum, the trade size can never be less than 1 lot (see remarks). [...].


I am coming from the MT4 world, where Lots can be "microlot". The reason I could not close partially by modifying TradeLots is because I tried to change to 0.5. For further readers: also check the Hedge mode.
© 2024 lite-C Forums