//------at_ALR(V)------------------- #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 SlateGray #property indicator_color4 SlateGray #property indicator_color5 Gold #property indicator_width1 2 #property indicator_width2 2 #property indicator_style3 2 #property indicator_style4 2 #property indicator_style5 2 #property indicator_level1 0 //--------------------------------- extern double hrLR=24; extern double kSig=0.3; extern double k=1.0; extern double Rd=0.05; //--------------------------------- double alr[],alra[],alrH[],alrL[],sqH[],sqL[],ma[]; //--------------------------------- double sx,sy,syp,sxy,sxyp,sxx,aa,bb,S; double rd,abs; int p,pma,fs,fss; //------------------------------------ int init() { IndicatorBuffers(7); //--------------------------------------------------- IndicatorShortName("ang_ALR(V) "+DoubleToStr(hrLR,0)); //--------------------------------------------------- SetIndexBuffer(0,alrH); SetIndexBuffer(1,alrL); SetIndexBuffer(2,sqH); SetIndexBuffer(3,sqL); SetIndexBuffer(4,ma); //------------------------ SetIndexBuffer(5,alr); SetIndexBuffer(6,alra); //------------------------ SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); //------------------------------- SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_HISTOGRAM); //------------------------------- return(0); } //************************************************* int start() { int cbi,cbi2,IC=IndicatorCounted(); if (Bars-IC<3) cbi=Bars-IC-1; else { p=hrLR*60/Period()+1; pma=p*kSig; cbi=Bars-p-1; cbi2=cbi-p-pma; } //========================================== for(int i=cbi; i>=0; i--) { sx=0.0; sy=0.0; sxy=0.0; sxx=0.0; for (int n=i; n<i+p; n++) { sx+=n; sy+=Close[n]; sxy+=n*Close[n]; sxx+=MathPow(n,2); } aa=(sx*sy-p*sxy)/(MathPow(sx,2)-p*sxx); bb=(sy-aa*sx)/p; //----------------------------- alr[i]=-aa*p/Point/hrLR; alra[i]=MathAbs(alr[i]); if (Rd!=0) { if (alr[i]>0) {if (fss==2) rd=0.0; fss=1;} if (alr[i]<0) {if (fss==1) rd=0.0; fss=2;} if (alr[i]>=rd+Rd || alr[i]<=rd-Rd) rd=MathRound(alr[i]/Rd)*Rd; alr[i]=rd; } if (alr[i]>alr[i+1]) fs=1; if (alr[i]<alr[i+1]) fs=2; if (fs==1) {alrH[i]=alr[i]; alrL[i]=0.0;} if (fs==2) {alrL[i]=alr[i]; alrH[i]=0.0;} } //=========================================== for (i=cbi2; i>=0; i--) { ma[i]=iMAOnArray(alr,0,pma,0,0,i); abs=iMAOnArray(alra,0,p,0,0,i)*k; sqH[i]=abs; sqL[i]=-abs; } //=========================================== 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_HISTOGRAM
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: