biobier » Fri Jun 03, 2022 11:56 am wrote:I have this issue only on my slow (busy) development system. I think that is the reason why only some ppl have that issue. The others run a proper sized system![]()
However there still is something more than the previous error... Created a test script (attached).
See this part of the output especially the time for CADCHF:Time=2022.04.28 12:45:00 WTF? 14:15 is the right one. Running the script again that symbol get the right time. Feel free to play around with the script. But I think we are getting closer....Code: Select all
0 13:42:09.307 GetBarDetails AUDUSD,M5: Details last bar for AUDUSD 15: Time=2022.06.03 14:15:00, Open=0.7243000000000001, High=0.72514, Low=0.7242499999999999, Close=0.72484, Volume=1047 0 13:42:09.320 GetBarDetails AUDUSD,M5: Details last bar for CADCHF 15: Time=2022.04.28 12:45:00, Open=0.75662, High=0.7571099999999999, Low=0.75621, Close=0.7569900000000001, Volume=1800 0 13:42:09.336 GetBarDetails AUDUSD,M5: CADCHF Got error (4066): requested history data is in update state Will etry 0 13:42:09.336 GetBarDetails AUDUSD,M5: Details last bar for CADCHF 15: Time=2022.04.28 12:45:00, Open=0.75662, High=0.7571099999999999, Low=0.75621, Close=0.7569900000000001, Volume=1800 0 13:42:09.336 GetBarDetails AUDUSD,M5: Details last bar for CADJPY 15: Time=2022.06.03 14:15:00, Open=103.481, High=103.534, Low=103.466, Close=103.514, Volume=1720
Thanks Biobier
I adapted the code to prevent the loading of open and close data from the wrong candle by checking for the timestamp:(on the assumption that if the right candle time is retrieved the data for iopen and iclose will be there as well)
double copen = 0;
double cclose = 0;
int k = 0;
GetLastError();//reset possible uncatched error
int err=GetLastError();
while ((closeEnough(copen, 0) ) && (k < 200) && (!IsStopped())){
if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
copen = iOpen(symbol, tf, 1);
err=GetLastError();
if(err>0) Sleep(10);
}
if (k==100) {RefreshRates();}
k++; }
//-----------
k = 0;
GetLastError();//reset possible uncatched error
err=GetLastError();
while ((closeEnough(cclose, 0) ) && (k < 200) && (!IsStopped())){
if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
cclose = iClose(symbol, tf, 1);
err=GetLastError();
if(err>0) Sleep(10);}
if (k==100) {RefreshRates();}
k++; }
direction = noney;//Default, and unlikely to happen but does sometimes
if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){
if (cclose >= copen)
{
direction = longy;
return;
}//if (cclose > copen)
if (cclose <= copen)
{
direction = shorty;
return;
}//if (cclose > copen)
}//if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){