2.33 brokerTrades(1);

Posted By: danatrader

2.33 brokerTrades(1); - 10/19/20 06:43

Used it with MT4 bridge, removed all trades from Zorro.

Did not add the missing ones, but removed all.
Assume I should not have done that, since on the MT4 bridge it does not state it is supported. blush
Posted By: danatrader

Re: 2.33 brokerTrades(1); - 10/19/20 08:03

Did install latest MT4 bridge, 2.06 vs. 2.09, maybe that is why?
Posted By: AndrewAMD

Re: 2.33 brokerTrades(1); - 10/19/20 09:44

No. Your plugin must support GET_TRADES for this to work correctly.
Posted By: danatrader

Re: 2.33 brokerTrades(1); - 10/19/20 09:59

Bad luck, did check the new MT4 bridge Version, didn't find it, just wanted to be sure.
Although, then besides me being silly, the bug is, that it does anything, although the brigde doesn't support it ---> very dangerous.


Possible solution, if tradestruct holds trades and brokerTrades(1) returns nothing or zero, throw message log.
Hint user to clean his trades if wanted by removing .trd file manually, or implement a force switch.
Posted By: jcl

Re: 2.33 brokerTrades(1); - 10/19/20 13:20

GET_TRADES returning zero can mean that this command is not supported, but also that no trade is open. You can use that command only when a) the plugin supports it and b) only a single Zorro instance trades with that broker and there is no manual trading. In other words, you must know exactly how and what for you want to use it.
Posted By: danatrader

Re: 2.33 brokerTrades(1); - 10/19/20 14:09

Exactly, so I would suggest if the plugin does not support it, it does nothing. Cause if trade struct contains trades, but even if plugin supports the command but for any reason returns "" or 0, it should not wipe the Trades from the struct.
Posted By: AndrewAMD

Re: 2.33 brokerTrades(1); - 10/19/20 14:13

Reread this:
Quote
GET_TRADES returning zero can mean that this command is not supported, but also that no trade is open.
Zorro does not necessarily know whether or not GET_TRADES is supported, but you do. The documentation will tell you whether or not GET_TRADES is supported. No trades detected means all your trades will get replaced with no trades. You should not expect any other behavior.
Posted By: danatrader

Re: 2.33 brokerTrades(1); - 10/19/20 14:31

From a developers point of view, that is totally correct.
Just since it does that without any further possibility do catch it, so even if you develop, and for any reason your API returns nothing, you can't catch that behaviour in your code, cause it just does what it does.

But besides that, it's just a question of perspective, i wonder @JCL do you plan on implementing that feature for MT4/5 bridge?
Cause that is really a nice one.
Posted By: AndrewAMD

Re: 2.33 brokerTrades(1); - 10/19/20 15:06

Okay, then let's talk about the "perspective":
Quote
even if plugin supports the command but for any reason returns "" or 0, it should not wipe the Trades from the struct.
If the broker shows that no trades are open, and your intent is to update your Zorro trades to synchronize with that of the broker, then it is only correct to delete all trades on the Zorro-side.

For example, if IB closes all of my positions (due to risk mitigation), I would certainly want my Zorro-side trades to be removed. If the Zorro-side trades were not removed, and I tried to close the trades on the Zorro side, I'd accidentally open a position in the wrong direction!
Posted By: danatrader

Re: 2.33 brokerTrades(1); - 10/19/20 16:16

Yes, you are right.
Thank you for sharing your thoughts about it and once you point it out, I fully agree.

I really would love that feature in MT4 / 5 too, it definitly is a really nice one.

Edit: I can confirm it works blush
© 2024 lite-C Forums