//+------------------------------------------------------------------+ //| Adaptive Moving Average | //| Denis Janulis | //+------------------------------------------------------------------+ #property copyright "Denis Janulis" #property link "denis.j@mits.lv" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- indicator parameters extern int n = 10; extern int p = 2; extern int q = 30; //---- indicator buffers double AMA[]; //---- int ExtCountedBars=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { int draw_begin; string short_name; //---- drawing settings SetIndexStyle(0,DRAW_LINE); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); SetIndexDrawBegin(0,draw_begin); //---- indicator buffers mapping SetIndexBuffer(0,AMA); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { double FC; double SC; double ER; double SSC; double c; int i = Bars-1; AMA[i+1] = Close[i]; while(i>=0) { //----- FC = (p+1); SC = (q+1); FC = 2/FC; SC = 2/SC; double V = 0; double D = Close[i]-Close[i+n]; for (int s = i; s <= i+n; s++) V = V + MathAbs(Close[s]-Close[s+1]); ER = D/V; SSC = ER*(FC-SC)+SC; c = SSC*SSC; //----- AMA[i] = AMA[i+1]+c*(Close[i]-AMA[i+1]); i--; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return(0); }
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: