Gamestudio Links
Zorro Links
Newest Posts
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 07/05/22 15:02
C++ scripts
by jcl. 07/04/22 13:02
History & HistoryFolder
by DdlV. 07/01/22 14:57
car.c how to add a trailer or wagon?
by Ice2642. 07/01/22 13:35
AUM Magazine
Latest Screens
DEAD TASTE
Tactics of World War I
Hecknex World
Scheherazade's Journey
Who's Online Now
5 registered members (KahunaTrading, AndrewAMD, Grant, MegaTanker, foox), 378 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
foox, Jiseb, faustotex, Anas, PeroPero
18793 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: 198
Netherlands
G
Grant Online OP
Member
Grant  Online OP
Member
G

Joined: Aug 2017
Posts: 198
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,834
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,834
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: 198
Netherlands
G
Grant Online OP
Member
Grant  Online OP
Member
G

Joined: Aug 2017
Posts: 198
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,834
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,834
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: 198
Netherlands
G
Grant Online OP
Member
Grant  Online OP
Member
G

Joined: Aug 2017
Posts: 198
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: 198
Netherlands
G
Grant Online OP
Member
Grant  Online OP
Member
G

Joined: Aug 2017
Posts: 198
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,834
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,834
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: 198
Netherlands
G
Grant Online OP
Member
Grant  Online OP
Member
G

Joined: Aug 2017
Posts: 198
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