//+------------------------------------------------------------------+ //| i-Moving_Average_all_TF_Real.mq4 | //| Copyright © 2010, MetaQuotes Software Corp. | //| "http://www.mql4.com/ru/users/costy_" | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, MetaQuotes Software Corp." #property link "http://www.mql4.com/ru/users/costy_" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- input parameters extern int tf = 240; extern int MaPeriod=14; extern int MaMethod=0; extern int price=0; extern int Shift=0; /* iCustom(0,0,"i-Moving_Average_all_TF_Real",tf,MaPeriod,MaMethod,4,price,Shift,i); */ double MaBuffer[], buf_arrey[]; datetime save_time; int i; void init(){ ArrayResize(buf_arrey,MaPeriod*10); ArraySetAsSeries(buf_arrey,true); if(tf=0; i--){ if(save_time!=iTime(0,tf, iBarShift(0,tf,Time[i]))){ save_time =iTime(0,tf, iBarShift(0,tf,Time[i])); for(int j=MaPeriod*10-1;j>0;j--) buf_arrey[j]=iMA(0,tf,1,0,0,price,j+iBarShift(0,tf,Time[i])); } buf_arrey[0]=Price(price); MaBuffer[i]=iMAOnArray(buf_arrey,0,MaPeriod,0,MaMethod,0); } } //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= // функция double Price(price); //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= double Price(int price){ switch(price){ case 0 : return (Close[i]); case 1 : return (iMA(0,tf,1,0,0,1,iBarShift(0,tf,Time[i]))); case 2 : int kol_vo_pois=iBarShift(0,0,iTime(0,tf, iBarShift(0,tf,Time[i])))-i; if(kol_vo_pois==0) return ( High[i]); return ( High[iHighest(0,0,MODE_HIGH,kol_vo_pois,i)]); case 3 : kol_vo_pois=iBarShift(0,0,iTime(0,tf, iBarShift(0,tf,Time[i])))-i; if(kol_vo_pois==0) return ( Low[i]); return ( Low[iLowest(0,0,MODE_LOW,kol_vo_pois,i)]); case 4 : kol_vo_pois=iBarShift(0,0,iTime(0,tf, iBarShift(0,tf,Time[i])))-i; if(kol_vo_pois==0) return ( (High[i]+Low[i])/2); return ( (High[iHighest(0,0,MODE_HIGH,kol_vo_pois,i)]+Low[iLowest(0,0,MODE_LOW,kol_vo_pois,i)])/2); case 5 : Print("Price not valide"); Comment("Price not valide"); return(0); case 6 : Print("Price not valide"); Comment("Price not valide"); return(0); } } //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= // функция string TF(); //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= string TF(){ switch(tf) { case 1 : return("M1"); case 5 : return("M5"); case 15 : return("M15"); case 30 : return("M30"); case 60 : return("H1"); case 240 : return("H4"); case 1440 : return("D1"); case 10080 : return("W1"); case 43200 : return("MN1"); default : return("Current"); } } //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=