MT4: Event values not populated

Discuss, post your questions about TWSLink here.

Users who just registered, please write an email to
forum@trade-commander.de
with your username mentioned.
So we can distinguish you from bots.
Thank you
Post Reply
aether
Posts: 6
Joined: Thu Jan 17, 2019 7:34 am

MT4: Event values not populated

Post by aether »

Hi,

I have the following small sample of code that connects to TWSLink and requests some historical data:

Code: Select all

#property copyright "trade-commander.org"
#property link      "http://www.trade-commander.org/"

#include <twslink2.mqh>
#include <WinUser32.mqh>

void TWSLinkPrintEvent(int eventuid) {
  Print(GET_EVENT_VAL_I(eventuid,1), ", ",
        GET_EVENT_VAL_I(eventuid,2), ", ",
        GET_EVENT_VAL_I(eventuid,3), ", ",
        GET_EVENT_VAL_I(eventuid,4), ", ",
        GET_EVENT_VAL_D(eventuid,5), ", ",
        GET_EVENT_VAL_D(eventuid,6), ", ",
        GET_EVENT_VAL_D(eventuid,7), ", ",
        GET_EVENT_VAL_D(eventuid,8), ", ",
        A2U(GET_EVENT_VAL(eventuid,9)), ", ",
        A2U(GET_EVENT_VAL(eventuid,10)), ", ",
        A2U(GET_EVENT_VAL(eventuid,11)), ", ",
        A2U(GET_EVENT_VAL(eventuid,12)), ", ",
        GET_EVENT_VAL_D(eventuid,13), ", ",
        GET_EVENT_VAL_D(eventuid,14), ", ",
        GET_EVENT_VAL_I(eventuid,15), ", ",
        GET_EVENT_VAL_I(eventuid,16));
}

int      uidMSFT         	= 0;     // unique id for MSFT contract
int      uidOrderMSFT     = 0;     // unique id for MSFT order

int init()
{
  Print("Connecting...");
  int connect_status = CONNECT(U2A(""), 7497, 1, 1000);
  Print("Connection status: ", connect_status);
  
  if (connect_status > 0) {
    uidMSFT = REGISTER_CONTRACT(U2A("MSFT"), U2A("STK"), U2A("USD"), U2A("SMART"), U2A(""), U2A(""), U2A(""), 0.0, U2A(""), 0, 0.0); // register MSFT  	
    int res = REQ_HIST_DATA(uidMSFT, U2A("20190101 00:00:00"), U2A("20181230 00:00:00"), 19 /*1 day*/, U2A("TRADES"), 1, 1, 1);
    Print("Req Hist Data return code = ", res);
    
    do {
      int eventuid = WAIT_FOR_EVENT(1000);
      if (eventuid > 0) {
        Print("Received event: ", eventuid);
        TWSLinkPrintEvent(eventuid);
      }
    } while (eventuid > 0);
  }
  return(1);
}

void deinit()
{ 
}
 
int start()
{
  return (1);
}
Running the code produces the output below. The problem is that the values from the events are all error codes signalling "event not found" (I have omitted most event outputs since they are all the same):

Code: Select all

0	20:25:02.613	twslinkdemo LTCBTC,H4: Connecting...
0	20:25:03.974	twslinkdemo LTCBTC,H4: Connection status: 3
0	20:25:04.105	twslinkdemo LTCBTC,H4: Req Hist Data return code = 1000007
0	20:25:04.122	twslinkdemo LTCBTC,H4: Received event: 5
0	20:25:04.449	twslinkdemo LTCBTC,H4: 2147483646, 2147483646, 2147483646, 2147483646, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, enf, enf, enf, enf, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 2147483646, 2147483646

(...)

0	20:25:19.367	twslinkdemo LTCBTC,H4: Received event: 71
0	20:25:19.580	twslinkdemo LTCBTC,H4: 2147483646, 2147483646, 2147483646, 2147483646, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, enf, enf, enf, enf, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, 2147483646, 2147483646
I am running Metatrader 4.0 build 1170 (20 dec 2018) on Windows 10.

The TWSLink log contains the following:

Code: Select all

20190120 20:25:02:752;      3888;note;tc_win_thread;InitInstance;THREAD <CDLLControlThread> started, id=3888
20190120 20:25:03:065;      2316;warning;tcContractUidMap;apply_xml_auto_uid_offset;new uidoffset 10000 < current offset 50004. new uid offset ignored
20190120 20:25:03:070;      2316;note;coreInstance;AutoOpenDBThreads;open databases threads...
20190120 20:25:03:076;      2316;note;DBThreadWrapper;fromXML;databases xmlid=1, dsn=twslink2demo connect=1 default=1
20190120 20:25:03:083;     18496;note;tc_win_thread;InitInstance;THREAD <CDBThread> started, id=18496
20190120 20:25:03:107;     18496;warning;CDBThread;PreTranslateMessage;failed to connect to database: twslink2demo,,
20190120 20:25:03:115;      2252;note;tc_win_thread;InitInstance;THREAD <IBSocket> started, id=2252
20190120 20:25:03:124;      2316;note;tcExpFunc;CONNECT;- -7497 -1 -1000
20190120 20:25:03:130;      2252;action;TWSSocket;Connect;connecting to TWS at 127.0.0.1::7497 client id=1...
20190120 20:25:03:137;      2252;note;TMP;connect;connecting to TWS at 127.0.0.1::7497 client id=1...
20190120 20:25:03:150;      2252;note;TWSSocket;Connect;waiting connect acknowledge...
20190120 20:25:03:157;      2252;action;TWSSocket;Connect;sending client version=63
20190120 20:25:03:163;      2252;action;TWSSocket;Connect;waiting for server version...
20190120 20:25:03:190;      2252;note;TMP;OnFirstReceive;2
20190120 20:25:03:198;      2252;note;TWSSocket;OnFirstReceive;server version=76
20190120 20:25:03:206;      2252;note;TMP;OnFirstReceive;3
20190120 20:25:03:214;      2252;note;TWSSocket;OnFirstReceive;twstime=20190120 20:25:00 CET
20190120 20:25:03:221;      2252;action;TWSSocket;OnFirstReceive;sending client id=1
20190120 20:25:03:230;      2252;action;TWSSocket;FinishRequest;command [send_client_id 70] transmitted. Bytes sent=7
20190120 20:25:03:246;      2252;action;TWSSocket;OnFirstReceive;connection phase 1 completed
20190120 20:25:03:254;      2252;note;TMP;OnFirstReceive;wait for managed accounts...
20190120 20:25:03:260;      2252;note;TWSSocket;OnFirstReceive;wait for managed accounts...
20190120 20:25:03:270;      2252;note;TMP;OnFirstReceive;end
20190120 20:25:03:289;      2252;note;CAccountVals;InitAccountList start;U2504908
20190120 20:25:03:295;      2252;note;CAccountVals;InitAccountList;account detected: acc_1  FA-type=no nbr=0
20190120 20:25:03:302;      2252;note;TMP;PostConnection;1
20190120 20:25:03:309;      2252;note;TMP;PostConnection;2
20190120 20:25:03:316;      2252;note;TMP;PostConnection;3
20190120 20:25:03:323;      2252;note;TMP;PerformInitialRequests;1
20190120 20:25:03:331;      2252;note;TWSSocket;PerformInitialRequests;start... param=0 open order request=1
20190120 20:25:03:337;      2252;action;request_handler;Reset;
20190120 20:25:03:343;      2252;note;TMP;PerformInitialRequests;2
20190120 20:25:03:350;      2252;note;TMP;PerformInitialRequests;3
20190120 20:25:03:358;      2252;action;TWSSocket;FinishRequest;command [reqAccountSummary] transmitted. Bytes sent=157
20190120 20:25:03:377;      2252;note;TWSSocket;nextValidId;next valid id=3 received
20190120 20:25:03:384;      2252;note;CTWSSocket;SetNonOrderTicker;new non order ticker offset=1000003
20190120 20:25:03:396;      2252;note;API;;API-message: market data farm connection is ok:usfarm.nj code=2104 id=-1   
20190120 20:25:03:408;      2252;note;API;;API-message: market data farm connection is ok:afarm code=2104 id=-1   
20190120 20:25:03:422;      2252;note;API;;API-message: market data farm connection is ok:cafarm code=2104 id=-1   
20190120 20:25:03:435;      2252;note;API;;API-message: market data farm connection is ok:usopt code=2104 id=-1   
20190120 20:25:03:452;      2252;note;API;;API-message: market data farm connection is ok:usfarm code=2104 id=-1   
20190120 20:25:03:468;      2252;note;API;;API-message: hmds data farm connection is ok:euhmds code=2106 id=-1   
20190120 20:25:03:483;      2252;note;API;;API-message: hmds data farm connection is ok:ushmds code=2106 id=-1   
20190120 20:25:03:636;      2252;note;TWSSocket;updateAccountValue;base currency=USD
20190120 20:25:03:716;      2252;note;TWSSocket;accountSummaryEnd;reqid=1
20190120 20:25:03:728;      2252;note;TWSSocket;request_and_wait_for_account_updates2;finished
20190120 20:25:03:735;      2252;note;TMP;PerformInitialRequests;4
20190120 20:25:03:743;      2252;action;TWSSocket;FinishRequest;command [reqPositions] transmitted. Bytes sent=5
20190120 20:25:03:768;      2252;note;toHandler;AddContract;contract added: mult=1  #set=OPT#sbl=URA#lsl=URA   190418C00016000#cur=USD#exc=#pex=#exp=20190418#mul=100#mnt=0.0000000000#rgt=C#srk=16.0000000000#sit=#sid=#als=#cid=330605049#vld=0# #id=50006 context=portfolio update
20190120 20:25:03:775;      2252;note;RequestStack;AddDetailRequest;detail requests stacked=1, detail requests pending=0, other requests stored=0, type of current request=0
20190120 20:25:03:782;      2252;note;TWSSocket;position;postions of contract URA_OPT_USD_20190418_C_16.000000_100=75 conid=0 account=acc_1 context=updatePortfolio avg=25.0343000 calls=0 publish_pos=1 publish_pl=1
20190120 20:25:03:793;      2252;note;TWSSocket;positionEnd;
20190120 20:25:03:805;      2252;note;TWSSocket;request_and_wait_for_position_updates;finished
20190120 20:25:03:812;      2252;note;TMP;PerformInitialRequests;5
20190120 20:25:03:819;      2252;action;TWSSocket;FinishRequest;command [reqOpenOrders] transmitted. Bytes sent=4
20190120 20:25:03:833;      2252;action;TWSSocket;RequestOpenOrder;open orders requested
20190120 20:25:03:869;      2252;note;TWSSocket;request_and_wait_for_open_orders;finished
20190120 20:25:03:876;      2252;note;TMP;PerformInitialRequests;6
20190120 20:25:03:883;      2252;action;TWSSocket;FinishRequest;command [reqExecutions] transmitted. Bytes sent=20
20190120 20:25:03:896;      2252;note;TWSSocket;RequestExecutions;executions requested for account= clientid=1
20190120 20:25:03:931;      2252;note;TWSSocket;request_and_wait_for_executions;finished
20190120 20:25:03:938;      2252;note;TMP;PerformInitialRequests;7
20190120 20:25:03:945;      2252;note;TMP;PerformInitialRequests;8
20190120 20:25:03:952;      2252;note;TMP;PerformInitialRequests;9
20190120 20:25:03:959;      2252;note;TMP;PerformInitialRequests;10
20190120 20:25:03:967;      2316;note;tcExpFunc;CONNECT;ret=3
20190120 20:25:03:974;      2252;note;TWSSocket;PostConnection;connection and initial requests done.
20190120 20:25:03:982;      2316;note;tcExpFunc;REGISTER_CONTRACT;-MSFT -STK -USD -SMART - - - -0.0000000000 - -0 -0.0000000000
20190120 20:25:03:989;      2252;note;toHandler;AddContract;contract added: mult=0  #set=STK#sbl=MSFT#lsl=#cur=USD#exc=SMART#pex=#exp=#mul=#mnt=0.0000000000#rgt=#srk=0.0000000000#sit=#sid=#als=#cid=0#vld=0# #id=50007 context=RegisterContract
20190120 20:25:03:996;      2252;action;TWSSocket;FinishRequest;command [reqContractDetails] transmitted. Bytes sent=44
20190120 20:25:04:011;      2252;action;toHandler;PerformDetailRequest;details requested for contract #set=STK#sbl=MSFT#lsl=#cur=USD#exc=SMART#pex=#exp=#mul=#mnt=0.0000000000#rgt=#srk=0.0000000000#sit=#sid=#als=#cid=0#vld=0# #id=50007 reqid=1000006
20190120 20:25:04:018;      2252;note;RequestStack;AddDetailRequest;detail requests stacked=0, detail requests pending=1, other requests stored=0, type of current request=0
20190120 20:25:04:026;      2316;note;tcExpFunc;REGISTER_CONTRACT;ret=50007
20190120 20:25:04:033;      2316;note;tcExpFunc;REQ_HIST_DATA;-50007 -20190101 00:00:00 -20181230 00:00:00 -19 -TRADES -1 -1 -1
20190120 20:25:04:105;      2316;note;tcExpFunc;WAIT_FOR_EVENT;-1000
20190120 20:25:04:114;      2316;note;tcExpFunc;WAIT_FOR_EVENT;ret=5
20190120 20:25:04:122;      2316;note;tcExpFunc;GET_EVENT_VAL_I;-5 -16
20190120 20:25:04:131;      2252;note;TWSSocket;contractDetails;details received (2) for contract=#set=STK#sbl=MSFT#lsl=MSFT#cur=USD#exc=SMART#pex=NASDAQ#exp=#mul=#mnt=0.0100000000#rgt=#srk=0.0000000000#sit=#sid=#als=#cid=272093#vld=1# #id=50007
20190120 20:25:04:138;      2316;note;tcExpFunc;GET_EVENT_VAL_I;ret=2147483646
20190120 20:25:04:149;      2316;note;tcExpFunc;GET_EVENT_VAL_I;-5 -15
20190120 20:25:04:157;      2316;note;tcExpFunc;GET_EVENT_VAL_I;ret=2147483646
20190120 20:25:04:163;      2316;note;tcExpFunc;GET_EVENT_VAL_D;-5 -14
20190120 20:25:04:170;      2252;note;RequestStack;AddDetailRequest;detail requests stacked=0, detail requests pending=0, other requests stored=0, type of current request=0
20190120 20:25:04:177;      2316;note;tcExpFunc;GET_EVENT_VAL_D;ret=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
20190120 20:25:04:184;      2316;note;tcExpFunc;GET_EVENT_VAL_D;-5 -13
20190120 20:25:04:191;      2252;error;tcsqliteDB;execute;error db=c:\trade-commander\twslink2\hdata\MSFT_STK_SMART__0_TRADES_1 day.sqlite , code=1: duplicate column name: generic (ALTER TABLE history ADD COLUMN generic BOOLEAN)
20190120 20:25:04:199;      2252;error;tcsqliteDB;createTable;ALTER TABLE history ADD COLUMN generic BOOLEAN
20190120 20:25:04:206;      2316;note;tcExpFunc;GET_EVENT_VAL_D;ret=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
20190120 20:25:04:213;      2252;error;tcsqliteDB;execute;error db=c:\trade-commander\twslink2\hdata\MSFT_STK_SMART__0_TRADES_1 day.sqlite , code=1: duplicate column name: changed (ALTER TABLE history ADD COLUMN changed BOOLEAN)
20190120 20:25:04:221;      2252;error;tcsqliteDB;createTable;ALTER TABLE history ADD COLUMN changed BOOLEAN
20190120 20:25:04:229;      2316;note;tcExpFunc;GET_EVENT_VAL;-5 -12
20190120 20:25:04:237;      2316;note;tcExpFunc;GET_EVENT_VAL;ret=enf
20190120 20:25:04:244;      2316;note;tcExpFunc;GET_EVENT_VAL;-5 -11
20190120 20:25:04:251;      2316;note;tcExpFunc;GET_EVENT_VAL;ret=enf
20190120 20:25:04:258;      2316;note;tcExpFunc;GET_EVENT_VAL;-5 -10
20190120 20:25:04:265;      2316;note;tcExpFunc;GET_EVENT_VAL;ret=enf
20190120 20:25:04:273;      2252;error;tcsqliteDB;execute;error db=c:\trade-commander\twslink2\hdata\MSFT_STK_SMART__0_TRADES_1 day.sqlite , code=1: duplicate column name: corrected (ALTER TABLE history ADD COLUMN corrected BOOLEAN)
20190120 20:25:04:281;      2252;error;tcsqliteDB;createTable;ALTER TABLE history ADD COLUMN corrected BOOLEAN
20190120 20:25:04:288;      2316;note;tcExpFunc;GET_EVENT_VAL;-5 -9
20190120 20:25:04:296;      2316;note;tcExpFunc;GET_EVENT_VAL;ret=enf
20190120 20:25:04:304;      2252;error;tcsqliteDB;execute;error db=c:\trade-commander\twslink2\hdata\MSFT_STK_SMART__0_TRADES_1 day.sqlite , code=1: duplicate column name: extern (ALTER TABLE history ADD COLUMN extern BOOLEAN)
20190120 20:25:04:311;      2316;note;tcExpFunc;GET_EVENT_VAL_D;-5 -8
20190120 20:25:04:319;      2252;error;tcsqliteDB;createTable;ALTER TABLE history ADD COLUMN extern BOOLEAN
20190120 20:25:04:326;      2316;note;tcExpFunc;GET_EVENT_VAL_D;ret=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
20190120 20:25:04:336;      2316;note;tcExpFunc;GET_EVENT_VAL_D;-5 -7
20190120 20:25:04:344;      2316;note;tcExpFunc;GET_EVENT_VAL_D;ret=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
20190120 20:25:04:352;      2316;note;tcExpFunc;GET_EVENT_VAL_D;-5 -6
20190120 20:25:04:364;      2316;note;tcExpFunc;GET_EVENT_VAL_D;ret=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
20190120 20:25:04:372;      2316;note;tcExpFunc;GET_EVENT_VAL_D;-5 -5
20190120 20:25:04:380;      2316;note;tcExpFunc;GET_EVENT_VAL_D;ret=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
20190120 20:25:04:389;      2316;note;tcExpFunc;GET_EVENT_VAL_I;-5 -4
20190120 20:25:04:396;      2316;note;tcExpFunc;GET_EVENT_VAL_I;ret=2147483646
20190120 20:25:04:405;      2316;note;tcExpFunc;GET_EVENT_VAL_I;-5 -3
20190120 20:25:04:414;      2316;note;tcExpFunc;GET_EVENT_VAL_I;ret=2147483646
20190120 20:25:04:421;      2316;note;tcExpFunc;GET_EVENT_VAL_I;-5 -2
20190120 20:25:04:429;      2316;note;tcExpFunc;GET_EVENT_VAL_I;ret=2147483646
20190120 20:25:04:435;      2316;note;tcExpFunc;GET_EVENT_VAL_I;-5 -1
20190120 20:25:04:442;      2316;note;tcExpFunc;GET_EVENT_VAL_I;ret=2147483646

(...similar repeated events omitted...)
This problems seems to be similar or the same as the one described here: viewtopic.php?f=3&t=42

Are the database errors in the log the cause of this?

I will be most thankful for any help with this issue.

aether
Posts: 6
Joined: Thu Jan 17, 2019 7:34 am

Re: MT4: Event values not populated

Post by aether »

*bump*

Any suggestions on this issue? Just a hint on what might be the cause of this will be very much appreciated!

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: MT4: Event values not populated

Post by board_admin »

I will check asap.
What TWS version please ?

(Please always use latest stable, which currently is 972)

aether
Posts: 6
Joined: Thu Jan 17, 2019 7:34 am

Re: MT4: Event values not populated

Post by aether »

I can confirm that I am using the latest version of twslink, downloaded January 17, 2019 from this link: https://trade-commander.com/download/2148/
Last edited by aether on Fri Feb 01, 2019 1:44 pm, edited 1 time in total.

aether
Posts: 6
Joined: Thu Jan 17, 2019 7:34 am

Re: MT4: Event values not populated

Post by aether »

I am running IB Trader Workstation build 974.4k Jan 29 2019 (Just updated, issue persists)

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: MT4: Event values not populated

Post by board_admin »

No, you should not update. Never use latest version, always stable please.

The current stable is 972.1p

https://www.interactivebrokers.com/en/index.php?f=16045

On this site lower right (Offline TWS)

https://www.interactivebrokers.com/en/i ... s-software

I test only on stable version.

---
I made your request and my events were all populated and also the database created in

Code: Select all

c:\trade-commander\twslink2\hdata\MSFT_STK_SMART__0_TRADES_1 day.sqlite
is populated with values of request.

In your log is a problem which points to an error on creating database to buffer historical data.

Code: Select all

2252;error;tcsqliteDB;execute;error db=c:\trade-commander\twslink2\hdata\MSFT_STK_SMART__0_TRADES_1 day.sqlite , code=1: duplicate column name: generic (ALTER TABLE history ADD COLUMN generic BOOLEAN)
I am not sure, but possible this error breaks the request at all. This error points to a version mismatch twslink/database.
What you could do:
1. Make sure to use correct TWS
2. Make sure to use correct (latest) TWSLink (version 2.3.07 https://trade-commander.com/download/2148/)
(may be do a clean install)
3. Rename folder

Code: Select all

c:\trade-commander\twslink2\hdata
to

Code: Select all

c:\trade-commander\twslink2\hdata.old
This forces on next request a database recreation.
This request should also provide correct values in event callback.

aether
Posts: 6
Joined: Thu Jan 17, 2019 7:34 am

Re: MT4: Event values not populated

Post by aether »

I have now done everything you suggested (install TWS offline version 972.1p, reinstall twslink, rename hdata folder).

The issue still persists. However, by experimenting I have discovered that I get data if I add 1 to the uid of latest event:

Code: Select all

do {
  int eventuid = WAIT_FOR_EVENT(1000);
  if (eventuid > 0) {
    Print("Event data: ", A2U(GET_EVENT_VAL(eventuid + 1, 0)));
  }
} while (eventuid > 0);
Does this make any sense? Or is there an "off by one" error in the twslink code, when events are handled without a callback?

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: MT4: Event values not populated

Post by board_admin »

I could reproduce this.

Please checkout the fix:

https://trade-commander.com/download/2148/

Just install.

aether
Posts: 6
Joined: Thu Jan 17, 2019 7:34 am

Re: MT4: Event values not populated

Post by aether »

Great, thank you very much! I can confirm it works on my machine as well.

Post Reply