MT4 Bridge Magic and comments with multiple scripts + Z12

Posted By: vinsom

MT4 Bridge Magic and comments with multiple scripts + Z12 - 02/12/17 11:03

I have several Zorro scripts + Z12 running on the same account.
I'm trying to set up different magic numbers for each script and different comment for each algos.
At the moment all magics and comments get messed up as mt4 global variables are overwritten by other scripts before the OrderSend happen.
I haven't found any way to let this work properly.
There are the issues I found:

- All strategies get a hardcoded magic when no other magic is set with command SET_MAGIC
- The SET_ORDERTEXT and SET_MAGIC are called at different time from the OrderSend call, therefore other scripts override the global variables where magic and comment are saved, and all magics and comments are messed up.
- I coded a queue, so that all custom strategies would wait for the previous one to set the magic and comment and call OrderSend before allowing another OrderSend to happen, but wouldn't work for Z12 as I can't change the code to let her wait.
- There is no way to add a parameter to identify the caller for the enterLong/enterShort to build a communication channel.

Having several Zorro scripts + Z12 running on the same account , is very important for me to distinguish the trades between the different strategies running.
At the moment is impossible for me to do this.
And the Zorro stats are reset at each restart, so they are pretty much useless in case you need to restart strategies from times to times.

Does anyone has any better idea on how to achieve this ?

Thanks
Vincenzo
Posted By: jcl

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 02/14/17 16:59

We got complaints of this already from another user, so we'll probably implement something in the bridge for connecting order text and magic to a certain order.

Until then, you can solve this by implementing a simple handshake. Edit the Zorro EA and add a new brokerCommand that just sets and reads a global variable. Before setting the order parameters, read that variable and wait until it is zero. Then set it to nonzero, set your parameters, call the buy command, and set it back to zero.
Posted By: DavidB1969

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/08/20 12:14

Originally Posted by jcl
We got complaints of this already from another user, so we'll probably implement something in the bridge for connecting order text and magic to a certain order.


What is the current status of the proposed fix?

David
Posted By: jcl

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/08/20 17:32

That was 3 years ago. I don't recall the state of things so far back, but you can find all about connecting comments to orders in the manual.
Posted By: DavidB1969

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/09/20 16:44

Thanks for your prompt reply. I guess this hasn't been picked up yet since I experience occasional mix ups of order, magic# and comment.
I will try to solve it with a workaround in the bridge EA as per your suggestion. And I'll add a request to the future features.
Posted By: jcl

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/10/20 13:27

What exactly is the problem? Comment and magic are stored for the next trade. You can set a lock for not getting interrupted. There should be no mixup.

https://manual.zorro-project.com/lock.htm
Posted By: matchristrading

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/11/20 14:12

I too experience a mixup of magic number and ordercomment. I have 5 Zorro strategies running. They all trade on one MT4 instance. I would like to give the all trades of one strategy the same magic number and comment, so I can distinguish in MT4 which trades belong to which strategy. But the magic number and ordercomment get mixed up. In the file attachments you can see that the same magic number is related with two different ordercomments. That should not be the case. One of the combinations is the correct one, as you can see in the code of the Zorro strategy.
In the two attachments that show some trades, you can seen that the comment "xsgap" in one trade is associated with magic number 100 and in another trade is associated with magic number 500. The third attachment shows the two lines of code in the strategy "xsgap". There you can see that the magic number of all trades of this strategy should be 500. The combination of comment "xsgap" and magic number 100 should not occur. I do not run a strategy that in his code combines comment "xsgap" with magic number 100. So there is a mixup of comments and magic numbers form different strategies into one trade that should not occur.

Attached picture Schermafdruk van 2020-01-11 15-02-34.png
Attached picture Schermafdruk van 2020-01-11 15-02-55.png
Attached picture Schermafdruk van 2020-01-11 15-05-02.png
Posted By: Petra

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/12/20 08:26

If you cant solve that on your own you have always the option to get help from zorro support.
Posted By: matchristrading

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/14/20 06:23

Thanks a lot for the hint to the lock statement. I think that will give the solution!!! Either the general lock or the lock as an option in the brokerCommand statement
Posted By: DavidB1969

Re: MT4 Bridge Magic and comments with multiple scripts + Z12 - 01/17/20 14:29

I added the brokerCommand(SET_LOCK,1) / brokerCommand(SET_LOCK,0) statements and tested it succesfully with 7 parallel Zorro instances coupled to a single MT4 instance. It works very well. Thank you so much for your support!
© 2024 lite-C Forums