//+------------------------------------------------------------------+ //| stock_volume.mq4 | //| Copyright 2014, Rondo | //| http://fx-dollaryen.seesaa.net | //+------------------------------------------------------------------+ #property copyright "Rondo" #property link "http://fx-dollaryen.seesaa.net/" #property version "1.0" #property description "Filesフォルダーにcsvファイルを入れてください。" #property strict //---- indicator settings #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 clrLimeGreen #property indicator_width1 2 input string FileName = "Dow.csv"; //csvファイル //---- indicator buffers double stockVolume[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit(){ //---- drawing settings SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexBuffer(0, stockVolume); IndicatorShortName("stock_volume ("+FileName+")"); SetIndexLabel(0, FileName+"Volume"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]){ if(rates_total == prev_calculated) return(0); int handle1 = FileOpen(FileName, FILE_CSV|FILE_READ, ","); if(handle1>0){ for(int i=0; i 2013.5.29 while(true){ if(StringFind(strDate, "/")>0){ int position = StringFind(strDate, "/"); string frontDate = StringSubstr(strDate, 0, position); string backDate = StringSubstr(strDate, position+StringLen("/")); strDate = frontDate + "." + backDate; } else break; } if(StringFind(strDate, ".")<0) break; int index = iBarShift(NULL, 0, StrToTime(strDate), true); if(index >= 0){ double open1 = FileReadNumber(handle1); double high1 = FileReadNumber(handle1); double low1 = FileReadNumber(handle1); double close1 = FileReadNumber(handle1); double volume1 = FileReadNumber(handle1); stockVolume[index] = volume1; } else{ FileReadNumber(handle1); FileReadNumber(handle1); FileReadNumber(handle1); FileReadNumber(handle1); FileReadNumber(handle1); } } } else{ Print("File my_data.dat not found, the last error is ", GetLastError()); return(false); } FileClose(handle1); return(0); }