//------------------------------------------------------------------- // original : ANG3110 // this version : mladen //------------------------------------------------------------------- #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 LightSlateGray #property indicator_color2 DodgerBlue #property indicator_color3 SandyBrown #property indicator_color4 SandyBrown #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; extern int period = 14; extern int Level = 25; double ADX[],ADXLa[],ADXLb[],DI[],slope[]; string indicatorFileName; bool returnBars; //------------------------------------------------------------------- // //------------------------------------------------------------------- // // // // // int init() { IndicatorBuffers(5); SetIndexBuffer(0,DI); SetIndexBuffer(1,ADX); SetIndexBuffer(2,ADXLa); SetIndexBuffer(3,ADXLb); SetIndexBuffer(4,slope); SetLevelValue(0,0); SetLevelValue(1, Level); SetLevelValue(2,-Level); indicatorFileName = WindowExpertName(); returnBars = (TimeFrame==-99); TimeFrame = MathMax(TimeFrame,_Period); IndicatorShortName(timeFrameToString(TimeFrame)+" ADXm ("+period+")"); return(0); } //------------------------------------------------------------------- // //------------------------------------------------------------------- // // // // // double work[][4]; #define zdh 0 #define zdl 1 #define zdx 2 #define _slope 3 int start() { int i,r,counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; double alpha = 2.0/(period+1); int limit = MathMin(Bars-counted_bars,Bars-1); if (returnBars) { DI[0] = limit+1; return(0); } // // // // // if (TimeFrame == Period()) { if (ArrayRange(work,0)!=Bars) ArrayResize(work,Bars); if (work[limit][_slope]==-1) CleanPoint(limit,ADXLa,ADXLb); for (i=limit,r=Bars-i-1; i>=0; i--,r++) { if (i==Bars-1) { work[r][zdh] = 0; work[r][zdl] = 0; work[r][zdx] = 0; continue; } double H = High[i]; double L = Low[i]; double dh = MathMax(H-High[i+1],0); double dl = MathMax(Low[i+1]-L ,0); if(dh==dl) {dh=0; dl=0;} else if(dh