//+------------------------------------------------------------------+ //| Demo_FileReadDouble.mq5 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //---- plot Label1 #property indicator_label1 "MA" #property indicator_type1 DRAW_LINE #property indicator_color1 clrGreen #property indicator_style1 STYLE_SOLID #property indicator_width1 2 #property indicator_separate_window //--- data reading parameters input string InpFileName="MA.csv"; // file name input string InpDirectoryName="Data"; // directory name //--- global variables int ind=0; int size=0; double ma_buff[]; datetime time_buff[]; //--- indicator buffer double buff[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- open the file ResetLastError(); int file_handle=FileOpen(InpDirectoryName+"//"+InpFileName,FILE_READ|FILE_BIN); if(file_handle!=INVALID_HANDLE) { PrintFormat("%s file is available for reading",InpFileName); PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH)); //--- first, read the amount of data in the file size=(int)FileReadDouble(file_handle); //--- allocate memory for the arrays ArrayResize(ma_buff,size); ArrayResize(time_buff,size); //--- read data from the file for(int i=0;i