Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Edgar_Herrera, VoroneTZ, Akow), 973 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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