Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trade execution during connection problems #486177
06/16/22 12:55
06/16/22 12:55
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Sometimes an order is send right before or during a connection problem with my MT4 broker and therefore isn't executed (Warning 075).

To workaround this problem, I've placed the following simplified code in a tock() (not tick() since my strategy is multi-asset):

Code
Trade = enterLong();
ThisTrade = Trade;

if(Trade != 0)
	{
  //Trade has been executed
	}
else
	{
  //Trade hasn't been executed	
	}


This code gets repeated during every tock() call as long as the order hasn't been executed.

However, once the broker connection gets reestablished, two orders get filled right after each other, so I considered placing a wait() function after 'ThisTrade...', but according to the manual this freezes the order execution process. A call() function doesn't seem a solution either because it has no mode for opening a trade (only closing and a couple of others).

Any suggestions to workaround this issue? Thanks.



Last edited by Grant; 06/16/22 16:24.
Re: Trade execution during connection problems [Re: Grant] #486184
06/17/22 10:30
06/17/22 10:30
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
For repeatedly sending orders until one is executed, the normal way is virtual hedging combined with a tradeUpdate call in a tock function.

void tock() { tradeUpdate(); }

Re: Trade execution during connection problems [Re: Grant] #486185
06/17/22 13:38
06/17/22 13:38
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Thank you for your suggestion, JCL.

So when MaxLong is larger than 1, I should use the following?

NFA set on 0 in accounts.csv

Code
run()
{
Hedge = 5;
}

tock()
{
ThisTrade = enterLong();

tradeUpdate(ThisTrade,0,0,0,0);

if(ThisTrade != 0)
        {
     //Trade has been executed
        }
else
        {
     //Trade hasn't been executed	
        }
}

Last edited by Grant; 06/17/22 13:46.
Re: Trade execution during connection problems [Re: Grant] #486186
06/17/22 14:02
06/17/22 14:02
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
That would permanently open new trades. That is certainly not what you want.

Re: Trade execution during connection problems [Re: jcl] #486187
06/17/22 14:28
06/17/22 14:28
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Do you refer to the MaxLong setting? I did this because I have re-entry rules included.
I assume this has no effect on this exception handling procedure, correct?

The reason I mentioned this is to motivate my choice to set Hedge at 5, not 4.

Re: Trade execution during connection problems [Re: Grant] #486188
06/17/22 14:42
06/17/22 14:42
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Oh wait, you mean that I should run 'ThisTrade = enterLong();' only once and then checking it's status during every tock() call till it's filled?

Re: Trade execution during connection problems [Re: Grant] #486190
06/17/22 15:32
06/17/22 15:32
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, I meant that trade, and no, you need no extra checking at all. Just set Hedge = 5 and add the tock function that I posted above.

Hedge = 5 prevents connection issues and tradeUpdate() permanently synchronizes your MT4 account with your Zorro trades.

Re: Trade execution during connection problems [Re: Grant] #486191
06/17/22 15:56
06/17/22 15:56
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
OK, now I understand.

Thanks for your help JCL!


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1