//+------------------------------------------------------------------+ //| vola12.mq5 | //| Copyright 2011, alohafx | //| http://http://alohafx.blog36.fc2.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2011, alohafx" #property link "http://alohafx.blog36.fc2.com/" #property version "1.00" input string sym00="USDCHF"; input string sym01="GBPUSD"; input string sym02="EURUSD"; input string sym03="USDJPY"; input string sym04="USDCAD"; input string sym05="AUDUSD"; input string sym06="EURGBP"; input string sym07="EURAUD"; input string sym08="EURCHF"; input string sym09="EURJPY"; input string sym10="GBPJPY"; input string sym11="GBPCHF"; string symb[12]; int iATR_handle[12]; double AtrBuffer[],High[],Low[]; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { symb[0]=sym00; symb[1]=sym01; symb[2]=sym02; symb[3]=sym03; symb[4]=sym04; symb[5]=sym05; symb[6]=sym06; symb[7]=sym07; symb[8]=sym08; symb[9]=sym09; symb[10]=sym10; symb[11]=sym11; for(int i=0; i<12; i++) { iATR_handle[i] = iATR(symb[i],PERIOD_MN1,12); } ArraySetAsSeries(AtrBuffer,true); ArraySetAsSeries(High,true); ArraySetAsSeries(Low,true); //--- int filehandle,i,j,k,bw; double mon3; for(i=0; i<12; i++) { int copied; copied=CopyBuffer(iATR_handle[i],0,0,70,AtrBuffer); if(copied<70) return; CopyHigh(symb[i],PERIOD_MN1,0,70,High); CopyLow(symb[i],PERIOD_MN1,0,70,Low); filehandle=FileOpen("vola.csv",FILE_WRITE|FILE_READ|FILE_CSV); if(filehandle!=INVALID_HANDLE) { FileSeek(filehandle,0,SEEK_END); for(j=2005; j<=2010; j++) //High { k=(2010-j)*12+6; // <-- 2011/6 = 0 mon3=MathMax(High[k+2],MathMax(High[k+1],High[k])); bw=FileWrite(filehandle,High[k+2],High[k+1],High[k],mon3); FileSeek(filehandle,-4,SEEK_CUR); bw=FileWrite(filehandle,"\t"); FileSeek(filehandle,-4,SEEK_CUR); } FileSeek(filehandle,0,SEEK_END); for(j=2005; j<=2010; j++) //Low { k=(2010-j)*12+6; // <-- 2011/6 = 0 mon3=MathMin(Low[k+2],MathMin(Low[k+1],Low[k])); bw=FileWrite(filehandle,Low[k+2],Low[k+1],Low[k],mon3); FileSeek(filehandle,-4,SEEK_CUR); bw=FileWrite(filehandle,"\t"); FileSeek(filehandle,-4,SEEK_CUR); } FileSeek(filehandle,0,SEEK_END); for(j=2005; j<=2010; j++) //pips { k=(2010-j)*12+6; // <-- 2011/6 = 0 mon3=MathMax(High[k+2],MathMax(High[k+1],High[k]))-MathMin(Low[k+2],MathMin(Low[k+1],Low[k])); bw=FileWrite(filehandle,High[k+2]-Low[k+2],High[k+1]-Low[k+1],High[k]-Low[k],mon3); FileSeek(filehandle,-4,SEEK_CUR); bw=FileWrite(filehandle,"\t"); FileSeek(filehandle,-4,SEEK_CUR); } FileSeek(filehandle,0,SEEK_END); for(j=2005; j<=2010; j++) //ATR(12) { k=(2010-j)*12+6; // <-- 2011/6 = 0 mon3=(AtrBuffer[k+2]+AtrBuffer[k+1]+AtrBuffer[k])/3; bw=FileWrite(filehandle,NormalizeDouble(AtrBuffer[k+2],5),NormalizeDouble(AtrBuffer[k+1],5),NormalizeDouble(AtrBuffer[k],5),NormalizeDouble(mon3,5)); FileSeek(filehandle,-4,SEEK_CUR); bw=FileWrite(filehandle,"\t"); FileSeek(filehandle,-4,SEEK_CUR); } FileClose(filehandle); } } } //+------------------------------------------------------------------+