downloaded data does not match chart

 

The data I am getting from the iBands, iMacd nor Close() are matching my charts.  I ran this on H1 GBPUSD and the values in the output file do not match the chart

//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Moving Averages Convergence/Divergence"
#property strict

void OnStart()
{
   int file_handle=FileOpen("h1.csv",FILE_READ|FILE_WRITE|FILE_CSV);
   
   double   boll_top[]; 
   double   boll_bot[]; 
   double   macd_main[]; 
   double   macd_sign[]; 
   datetime date_buff[]; 
   string   line;
   
   int copied=CopyTime(NULL,PERIOD_H1,0,2000,date_buff);
   ArrayResize(boll_top,copied);   
   ArrayResize(boll_bot,copied);
   ArrayResize(macd_main,copied);   
   ArrayResize(macd_sign,copied);   
   FileWrite(file_handle,copied);
   for(int i=0;i<copied;i++)
   {
      boll_top[i]=iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,i);
      boll_bot[i]=iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,i);
      macd_main[i]=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i);
      macd_sign[i]=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i);
      line=TimeToString(date_buff[i])+"|"+DoubleToString(Close[i])+"|"+DoubleToString(boll_top[i])+"|"+DoubleToString(boll_bot[i])
          +"|"+DoubleToString(macd_main[i])+"|"+DoubleToString(macd_sign[i]);
      FileWrite(file_handle,line);
   }
   FileClose(file_handle);
}
 
jshumaker:

The data I am getting from the iBands, iMacd nor Close() are matching my charts.  I ran this on H1 GBPUSD and the values in the output file do not match the chart

Have you set the arrays as series? I don't think so.

https://www.mql5.com/en/docs/array/arraysetasseries
Documentation on MQL5: Array Functions / ArraySetAsSeries
Documentation on MQL5: Array Functions / ArraySetAsSeries
  • www.mql5.com
//| Custom indicator initialization function                         | //| Custom indicator iteration function                              |
Reason: