BrokerTrade and manual partial closing

Posted By: byakuren81

BrokerTrade and manual partial closing - 03/13/22 14:23

Hello,

I noticed the method BrokerTrade for writing broker APIs does not work when partially closing a trade manually. It will only work when closing it fully.
Do you confirm it is currently the case and not me doing something wrong?
If it is, it would be interesting to have this functionality in the future.
Posted By: Petra

Re: BrokerTrade and manual partial closing - 03/14/22 16:06

I am not sure because I think no one so far had the idea to close a trade manually partially. But BrokerTrade should still work, unless the API is NFA compliant or does otherwise not support BrokerTrade.
Posted By: byakuren81

Re: BrokerTrade and manual partial closing - 03/14/22 19:18

Thank you for your answer but I can confirm it does not work. My broker is not NFA compliant.
When I partially close a trade manually from the broker GUI, for instance 1 lot out of 3 initially opened, my BrokerTrade method returns -1 to tell Zorro 1 lot of this position has been closed, then during the next calls to BrokerTrade it returns 2 but Zorro trading engine does not update the TradeLots value on this trade and keeps the value 3.
When I close this trade through the Zorro GUI by clicking on Stop and Yes to the question "Close open trades?", my BrokerSell2 method gets 3 as nAmount argument showing this trade was not updated.
Posted By: Petra

Re: BrokerTrade and manual partial closing - 03/14/22 21:35

What plugin are you using? If Brokertrade returns wrong values you should report it.
Posted By: jcl

Re: BrokerTrade and manual partial closing - 03/15/22 07:36

If you wrote that function yourself: make sure that it really returns the number of open contracts when the trade is open. -1 would be wrong.

https://zorro-project.com/manual/en/brokerplugin.htm
Posted By: byakuren81

Re: BrokerTrade and manual partial closing - 03/17/22 20:12

That is what I do now but still Zorro does not update the tray closing a trade, it keeps the opening size in memory even if I return at some point a smaller positive number, so I conclude that partially closing a trade manually does not work.
However, it works without issue when fully closing manually.
Posted By: byakuren81

Re: BrokerTrade and manual partial closing - 03/17/22 20:28

My own plugin.
Posted By: jcl

Re: BrokerTrade and manual partial closing - 03/18/22 09:29

Ok, we'll check that. If it is indeed not supported, it will be implemented. It is probably no big deal.
Posted By: byakuren81

Re: BrokerTrade and manual partial closing - 03/18/22 19:22

Thank you, anyway the most important is to be able to fully close a trade manually and this works well.
Posted By: Zheka

Re: BrokerTrade and manual partial closing - 03/19/22 09:39

I too noticed Zorro "losing" a partially closed trade with MT4/5 plugin, unless Hedge>=4. Fixing that would be great.
© 2024 lite-C Forums