//+------------------------------------------------------------------+ //| SuperMomentum.mq4 | //| Copyright © 2009, RoboFx | //| http://www.robofx.org | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, RoboFx" #property link "http://www.robofx.org" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 LightBlue extern int FastPeriod = 4; extern int MiddlePeriod = 7; extern int SlowPeriod = 14; int fastK = 12, middleK = 3, slowK = 1; double SuperMomentum[]; double TempBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(2); SetIndexBuffer(0, SuperMomentum); SetIndexBuffer(1, TempBuffer); SetIndexDrawBegin(0,0); //SetIndexDrawBegin(1,0); SetIndexStyle(0, DRAW_HISTOGRAM,STYLE_SOLID,1); SetIndexStyle(1, DRAW_NONE); IndicatorShortName("Super Momentum ("+FastPeriod+","+MiddlePeriod+","+SlowPeriod+")"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i, counted_bars=IndicatorCounted(); //---- i=Bars-SlowPeriod-1; if(counted_bars>=SlowPeriod) i=Bars-counted_bars-1; while(i>=0) { TempBuffer[i]=fastK*(Close[i]-Close[i+FastPeriod]) + middleK*(Close[i]-Close[i+MiddlePeriod]) + slowK*(Close[i]-Close[i+SlowPeriod]); i--; } i=Bars-SlowPeriod-1; if(counted_bars>=SlowPeriod) i=Bars-counted_bars-1; while(i>=0) { SuperMomentum[i] = iMAOnArray(TempBuffer,WHOLE_ARRAY,FastPeriod,0,PRICE_CLOSE,i); i--; } //---- return(0); } //+------------------------------------------------------------------+