//+------------------------------------------------------------------+ //| MAMy.mq4 | //| Copyright © 2006, Victor Chebotariov | //| http://www.chebotariov.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, Victor Chebotariov" #property link "http://www.chebotariov.com/" //---- extern int period = 3; extern int ma_method = 3; //---- #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Red //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorShortName("MAMy(" + period + ", " + ma_method + ")"); //---- indicators SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, ExtMapBuffer1); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(1, ExtMapBuffer2); //---- return(0); } //+------------------------------------------------------------------+ //| Accumulation/Distribution | //+------------------------------------------------------------------+ int start() { int i, counted_bars = IndicatorCounted(); //---- i = Bars - counted_bars - 1; while(i >= 0) { double close = iMA(NULL, 0, period, 0, ma_method, 0, i); double open = iMA(NULL, 0, period, 0, ma_method, 1, i); double weighted = iMA(NULL, 0, period, 0, ma_method, 6, i); //---- ExtMapBuffer1[i] = ((weighted - open) + (close - weighted))*1000; ExtMapBuffer2[i] = (close - weighted)*1000; i--; } //---- return(0); } //+------------------------------------------------------------------+