Gamestudio Links
Zorro Links
Newest Posts
long time to load data
by qin. 12/31/25 09:57
The new evaluation shell
by jcl. 12/29/25 09:56
about Zorro S (monthly)
by AndrewAMD. 12/29/25 03:24
Xor Memory Problem.
by TipmyPip. 12/26/25 19:14
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (Quad, Jack_Zodiac), 3,316 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Syndrela, HDRSEO, AOUNZA, digitalboy381, agasior
19190 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Zorro not reconnecting to IB gateway after restart [Re: opm] #488958
10/24/25 00:23
10/24/25 00:23
Joined: Dec 2023
Posts: 11
Paddington
O
opm Offline OP
Newbie
opm  Offline OP
Newbie
O

Joined: Dec 2023
Posts: 11
Paddington
Hi, no. Its on my list to investigate again

Re: Zorro not reconnecting to IB gateway after restart [Re: opm] #489020
12/17/25 15:18
12/17/25 15:18
Joined: Jan 2021
Posts: 7
Austin, TX, USA
J
Jack_Zodiac Online
Newbie
Jack_Zodiac  Online
Newbie
J

Joined: Jan 2021
Posts: 7
Austin, TX, USA
Hi, is this still the state of things? I am wondering about trying to programmatically issue the re-connect commands to Zorro.

I'm using TWS, and it accepts connection fine after its daily re-start -- but Zorro has to be given 'stop', 'don't close trades', 'do stop trading', and then 'trade' button clicks, load prices, run through the lookback, and then everything works.

Re: Zorro not reconnecting to IB gateway after restart [Re: opm] #489021
12/18/25 08:43
12/18/25 08:43
Joined: Jul 2000
Posts: 28,044
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,044
Frankfurt
We'll soon do a new IB plugin version and will attempt a workaround of the problem on that occasion, although I cannot promise a perfect solution.

Re: Zorro not reconnecting to IB gateway after restart [Re: opm] #489059
Yesterday at 21:11
Yesterday at 21:11
Joined: Jan 2021
Posts: 7
Austin, TX, USA
J
Jack_Zodiac Online
Newbie
Jack_Zodiac  Online
Newbie
J

Joined: Jan 2021
Posts: 7
Austin, TX, USA
I made a work-around for this that seems to be working reliably enough for me. (I consider it a convenience rather than mission-critical.)

It involves using the system() command to kick off another Zorro instance shortly after the TWS restart, and quit() to kill the original one.

My implementation is likely sub-optimal, so comments welcomed. (But, no need to lecture me about global variables.)

I am running 64-bit Zorro C++ scripts on a Windows 11 machine, with an S-level license.

The following code is pieced together from the various functions where it actually resides and hasn't been tested in this exact form, so consider it just a sketch of concept. The core commands are in the last few lines, the rest is infrastructure.

-----------------------

// Globals
int Last_Started_Day, UTC_offset;
bool SOD_Business, SOD_Business Done, EOD_Business, EOD_Business_Done; // SOD = start of day, EOD = end of day
string State_File;

DLLFUNC void main()
{
// Delay to ensure previous Zorro instance has ended
if (is(TRADEMODE) && is(COMMAND))
{
printf("10 second delay for Zorro instance handoff...");
wait(10000);
}

State_File = "Data\\My_State_File.csv";

// other main() stuff....

}

DLLFUNC void run()
{
if (Bar == StartBar)
{
printf("\n");
printf("\nLoading State File...");

// Script-wide variables
Last_Started_Day = (int)(getvar(State_File, "Last_Started_Day"));
EOD_Business_Done = (bool)(getvar(State_File, "EOD_Business_Done"));

// other state stuff....
}

// TIME ZONE OFFSET
if (dst(EST,0)==1)
{
UTC_offset = -4;
}
else
{
UTC_offset = -5;
}

start_time = 0400 - UTC_offset*100;

// Daily business
SOD_Business_Done = day(0) == Last_Started_Day;
SOD_Business = tod(0) >= start_time && tod(0) < 2300 && !SOD_Business_Done;

if (SOD_Business)
{
Last_Started_Day = day(0);
SOD_Business_Done = true;
EOD_Business_Done = false;

// other start of day stuff ...
}

int EOD_time;
bool EOD_Window;
if (dst(EST,0)==1)
{
EOD_time = 2350;
EOD_Window = tod(0) >= EOD_time;
}
else
{
EOD_time = 50;
EOD_Window = tod(0) >= EOD_time && tod(0) < 200;
}

// TWS daily restart should be set for slightly before the EOD_time. E.g. currently I use 00:30 GMT

EOD_Business = EOD_Window && !EOD_Business_Done;

if (EOD_Business)
{
if (is(TRADEMODE) && Bar > StartBar && !EOD_Business_Done)
{
login(4);
EOD_Business_Done = true;
putvar(State_File, "EOD_Business_Done", (var)(EOD_Business_Done));
wait(10000);
system("Zorro64.exe -trade My_Script.cpp");
quit("!Restarting Zorro session to cope with IBKR lockout.");
}
}

}

Last edited by Jack_Zodiac; Yesterday at 21:13.
Page 2 of 2 1 2

Moderated by  Petra 

Gamestudio download | 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