I am having an issue while working on a correlation indicator; it reads USDCHF in the same time as EURUSD;
Code excerpt:
int startpos=prev_calculated+needed; //this is the start position ; it goes UPWARD, we are on an array, not on series for (int pos=startpos;pos<rates_total;pos++) //main cycle, going from startpos to rates_total
{
lastFirst=CopyRates(Symbol(),Period(),pos-BarCount,BarCount,mqlrFirst)-1;
dt0=mqlrFirst[0].time;
dt1=mqlrFirst[lastFirst].time;
Print("dt1=",TimeToString(dt1));
Print("dt0=",TimeToString(dt0));
lastSecond=CopyRates(Overlay,Period(),dt0,dt1,mqlrSecond)-1;
p=CopyRates(Overlay,Period(),dt1,dt1,mqlrfinal);
if(p>=1)
Print(pos," ",TimeToString(mqlrfinal[p-1].time,TIME_DATE)," -> ",DoubleToString(mqlrfinal[p-1].close,5));
elsePrint("*//*WTF?!//");
Print("last positions: ",lastFirst," ",lastSecond);
The loop is a bit larger, but the rest doesn't seem to be an issue. The task is simple: read a backward period of BarCount bars from EURUSD, get their start and end times, then read the same period from Overlay (USDCHF) (between dt0 and dt1). Also store the value corresponding to the dt1 bar on USDCHF.
Now look at the "last positions" log lines. There are plenty of lines with normal time, USDCHF data, that is not read (lastSecond=-2) ; at the same time, there is no "WTF!" meaning that the last value , corresponding of the dt1-dt1 bar on USDCHF, is read. Now how can that happen? Doesn't read dt0 to dt1, but reads dt1 to dt1 ?
Now the CopyRates selection with two datetimes doesn't work anymore at all ; it works the regular selection by bars and the selection with one daytime and a bar count.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I am having an issue while working on a correlation indicator; it reads USDCHF in the same time as EURUSD;
Code excerpt:
The loop is a bit larger, but the rest doesn't seem to be an issue. The task is simple: read a backward period of BarCount bars from EURUSD, get their start and end times, then read the same period from Overlay (USDCHF) (between dt0 and dt1). Also store the value corresponding to the dt1 bar on USDCHF.
Now look at the "last positions" log lines. There are plenty of lines with normal time, USDCHF data, that is not read (lastSecond=-2) ; at the same time, there is no "WTF!" meaning that the last value , corresponding of the dt1-dt1 bar on USDCHF, is read. Now how can that happen? Doesn't read dt0 to dt1, but reads dt1 to dt1 ?