Hi guys,
I've been trying to figure this one out. Maybe someone here can help me. I have this function that reads from a .csv and outputs the value into the indicator buffer, but ever since MT4 updated, its been broken. The error message is "array out of range". The compiler points to where the [c] array variable is.
This is what the input .csv file looks like.
I'm not really a coder, so its a little messy.
Any solution/suggestion would be much appreciated.
Thanks.
I've been trying to figure this one out. Maybe someone here can help me. I have this function that reads from a .csv and outputs the value into the indicator buffer, but ever since MT4 updated, its been broken. The error message is "array out of range". The compiler points to where the [c] array variable is.
Inserted Code
#property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Silver #property indicator_color2 Black int init() { IndicatorDigits(0); IndicatorShortName(""); SetIndexStyle(0,DRAW_LINE,STYLE_DOT,1,clrSilver); SetIndexBuffer(0,BALBuffer); SetIndexLabel(0,"BAL"); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,clrBlack); SetIndexBuffer(1,EQTBuffer); SetIndexLabel(1,"EQT"); return(0); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { GetChart(); return(0); } void GetChart() { string ECFile = "55033.csv"; string arr[5]; string tmp; datetime dt[2000]; double val1[2000]; double val2[2000]; int c,i=0; int h = FileOpen(ECFile, FILE_CSV|FILE_READ,'~'); for (int c=0; !FileIsEnding(h) && c<2000; c++) { tmp = FileReadString(h); if (FileIsEnding(h)) break; StrToStringArray(tmp,arr,","); dt[c] = StrToTime(StringSubstr(arr[0],6,4)+"."+StringSubstr(arr[0],3,2)+"."+StringSubstr(arr[0],0,2)); val1[c] = StrToNumber(arr[1]); val2[c] = StrToNumber(arr[2]); } FileClose(h); c--; for (int i=0; i<=Bars; i++) { while(Time[i] < dt[c]) c--; if (c >= 0) { BALBuffer[i] = val1[c]; EQTBuffer[i] = val2[c]; } } }
This is what the input .csv file looks like.
Inserted Code
03/02/2014,350306.85,350306.85 04/02/2014,350306.85,350306.85 05/02/2014,350306.85,350306.85 06/02/2014,350306.85,350306.85 07/02/2014,350306.85,350306.85 10/02/2014,350306.85,350306.85 11/02/2014,350306.85,350306.85 12/02/2014,350306.85,350306.85 13/02/2014,350306.85,350306.85 14/02/2014,349867.08,349867.08 17/02/2014,349867.08,349867.08 18/02/2014,349867.08,349867.08 19/02/2014,349867.08,349867.08 20/02/2014,349867.08,349867.08 21/02/2014,349867.08,349867.08 24/02/2014,349867.08,349867.08 25/02/2014,347892.08,347892.08 26/02/2014,347892.08,347892.08 27/02/2014,347892.08,347892.08 28/02/2014,347892.08,347892.08 03/03/2014,347892.08,347892.08 04/03/2014,347892.08,347892.08 05/03/2014,347892.08,347892.08 06/03/2014,347892.08,347892.08 07/03/2014,347892.08,347892.08 10/03/2014,347892.08,347892.08 11/03/2014,347892.08,347892.08 12/03/2014,347892.08,347892.08 13/03/2014,347453.05,347453.05 14/03/2014,347453.05,327345.29 17/03/2014,342426.72,326545.14 18/03/2014,342426.72,330496.66 19/03/2014,342426.72,339219.78 20/03/2014,342426.72,330867.13 21/03/2014,342426.72,331911.24 24/03/2014,342426.72,330336.21 25/03/2014,342426.72,335336.21 26/03/2014,342427.72,334545.23 27/03/2014,342427.72,338089.43 28/03/2014,337334.64,343461.25
I'm not really a coder, so its a little messy.
Any solution/suggestion would be much appreciated.
Thanks.