//+------------------------------------------------------------------+ //| mtf-ma.mq4 | //| Yury Zinoviev | //| https://sites.google.com/site/fxtraderz100 | //+------------------------------------------------------------------+ #property copyright "Yury Zinoviev" #property link "https://sites.google.com/site/fxtraderz100" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Yellow //inputs extern double tf = 1440; extern int period = 15; extern int method = 0; extern int shift = 0; //buffers double ma[]; double factor=0; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { if (Period()>tf) { Print("Wrong timeframe!"); return(-1); } SetIndexBuffer(0,ma); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1); SetIndexLabel(0,"MA "+tf); IndicatorShortName("Moving Average ("+tf+", "+period+")"); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int i=Bars-counted_bars; if(counted_bars==0) i--; double ctf=Period(); //Print("current tf="+ctf); double r=tf/ctf; //Print("r="+r); if (r!=0) while(i>=0) { int k=MathFloor(i/r); ma[i]=iMA(Symbol(),tf,period,shift,method,PRICE_CLOSE,k); i--; } return(0); } //+------------------------------------------------------------------+