//+------------------------------------------------------------------+ //| ADXBARSsmd[cw].mq4 | //| ADX Bars Smoothed [cw] Perky Ate no turkey | //| | //+------------------------------------------------------------------+ #property copyright "Perky" #property link "Perky_z@yahoo.com" //---- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Blue //---- indicator parameters extern int ADXPeriod = 14; extern int ADXBARSPeriod = 5; extern int Shift=0; extern int slShift=0; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double HighBarBuffer[]; double LowBarBuffer[]; double b4plusdi, b4minusdi, nowplusdi, nowminusdi; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //----additional buffers are used for counting. IndicatorBuffers(4); //---- indicator buffers mapping if(!SetIndexBuffer(0,ind_buffer1) && !SetIndexBuffer(1,ind_buffer2) && !SetIndexBuffer(2,HighBarBuffer) && !SetIndexBuffer(3,LowBarBuffer)) Print("cannot set indicator buffers!"); //---- drawing settings SetIndexStyle(0, DRAW_LINE); SetIndexShift(0, Shift+slShift+1); SetIndexStyle(1, DRAW_LINE); SetIndexShift(1, Shift); //---- IndicatorDigits(Digits + 1); //---- name for DataWindow and indicator subwindow label IndicatorShortName("ADXBarsSmd[cw]"); SetIndexLabel(0, "ADXBarsSmd[sw]("+ADXPeriod+","+ADXBARSPeriod+"s"+Shift+"sls"+slShift+")"); SetIndexLabel(1, "SignalADXsmd[sw]("+ADXPeriod+","+ADXBARSPeriod+"s"+Shift+")"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| ADX BARS | //+------------------------------------------------------------------+ int start() { double ArOsc = 0; int ArPer, limit, i; int counted_bars = IndicatorCounted(); //---- check for possible errors if(counted_bars < 0) return(-1); //---- last counted bar will be recounted if(counted_bars > 0) counted_bars--; limit = Bars - counted_bars; //----Calculation--------------------------- for(i = 0; i < limit; i++) { nowplusdi = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_PLUSDI, i); nowminusdi = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MINUSDI, i); if(nowminusdi > nowplusdi) { LowBarBuffer[i] = Low[i]; HighBarBuffer[i] = High[i]; } if(nowplusdi > nowminusdi) { HighBarBuffer[i] = Low[i]; LowBarBuffer[i] = High[i]; } } for(i = limit - 1; i >=0 ; i--) { ind_buffer1[i] = iMAOnArray(HighBarBuffer, 0, ADXBARSPeriod, 0, MODE_SMA, i); ind_buffer2[i] = iMAOnArray(LowBarBuffer, 0, ADXBARSPeriod, 0, MODE_SMA, i); } //---- done return(0); }
Sample
Analysis
Market Information Used:
Series array that contains the lowest prices of each bar
Series array that contains the highest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Movement directional index
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: