How to get the Closing Price for an exchange (e.g. USDCAD) at certain dates and times.

 

Hi I am running into some problems with my code:

timeAndDateArray[3]={"2018.07.20 8:29", "2018.07.20 8:30", "2018.07.20 8:31"};
int i = 0;
for (i=0; i<=2;i++){
printf(iClose("USDCAD",PERIOD_M1,iBarShift("USDCAD",PERIOD_M1,StrToTime(timeAndDateArray[i]))));
}

This just returns the same price over and over again (I checked to make sure it is different). What am I doing wrong? Also, how would I "append" these values to another array.


Thanks in advance!

 

if it always prints the close price for last bar only (bar #0), then probably iBarShift always returns -1

EDIT : define array type for  timeAndDateArray , if not already.


Eric Gennadivich: ... Also, how would I "append" these values to another array...

better to use one array from start. and just populate it with new values.

 
Eric Gennadivich: This just returns the same price over and over again
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

Reason: