Topics
03 Apr 2013, 14:38
3494
4
02 Apr 2013, 21:48
4856
6
04 Mar 2013, 09:57
5266
10
16 Oct 2012, 19:10
3954
5
Replies
virux84
27 Mar 2013, 16:28
RE:
cAlgo_Fanatic said:
This indicator cannot be converted fully with the current version of the API. However, drawing rectangles will be possible in a future release and then this indicator may be translated. If you wish, you may plot only the line of this indicator and we will help you with the code.
This draw only a line. Please help me.
Thank you anyway
#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Yellow #property indicator_width1 2 #property indicator_maximum 31 #property indicator_minimum 5 //---- int TimeFrame = 0; double DomCyc[]; double MaxAmpl; int draw_begin, mBars,pBars, mcnt_bars, per, win; datetime pTime; double Q[60], I[60], Real[60], Imag[60], Ampl[60], DB[60], OldI[60], OlderI[60], OldQ[60], OlderQ[60], OldReal[60], OlderReal[60], OldImag[60], OlderImag[60], OldDB[60]; double FuzzWidth = 0.5; int init() { string TF = "M5"; TimeFrame = Period(); per = 30; draw_begin=2*per*TimeFrame/Period(); IndicatorShortName("four"); SetIndexLabel(0,"Dom Cycle"); SetIndexBuffer(0,DomCyc); SetIndexStyle(0,DRAW_LINE); SetIndexDrawBegin(0,draw_begin); mBars = Bars; return(0); } void deinit() { ObjectsDeleteAll(win,OBJ_RECTANGLE); return(0); } int start() { int limit, y, i, shift, n, cnt_bars=IndicatorCounted(); double price[], mDomCyc[], DC[], SmoothHP[], HP[]; double pi = 4 * MathArctan(1); win = WindowFind("e"); mBars = Bars; if(mBars != pBars) { ArrayResize(price,mBars); ArrayResize(mDomCyc,mBars); ArrayResize(DC,mBars); ArrayResize(SmoothHP,mBars); ArrayResize(HP,mBars); pBars = mBars; } if(cnt_bars<1) { for(i=Bars-1;i>0;i--) DomCyc[i]=EMPTY_VALUE; mcnt_bars = 0; } if(mcnt_bars > 0) mcnt_bars--; for(y=mcnt_bars+1;y<mBars;y++) { price[y] = iMA(NULL,TimeFrame,1,0,0,0,mBars-y-1); double alpha1 = (1 - MathSin(2*pi/30)) / MathCos(2*pi/30); HP[y] = 0.5*(1 + alpha1)*(price[y] - price[y-1]) + alpha1*HP[y-1]; SmoothHP[y] = (HP[y] + 2.0*HP[y-1] + 3.0*HP[y-2] + 3.0*HP[y-3] + 2.0*HP[y-4] + HP[y-5]) / 12.0; if(y < 6) SmoothHP[y] = price[y] - price[y-1]; if(y == 0) SmoothHP[y] = 0; double delta = -0.015*(y+1) + 0.5; if(delta < 0.1) delta = 0.1; if(y > 11) { if(iTime(NULL,TimeFrame,mBars-y-1) != pTime) { for(n = 11; n<= 59; n++) { OlderI[n] = OldI[n]; OldI[n] = I[n]; OlderQ[n] = OldQ[n]; OldQ[n] = Q[n]; OlderReal[n] = OldReal[n]; OldReal[n] = Real[n]; OlderImag[n] = OldImag[n]; OldImag[n] = Imag[n]; OldDB[n] = DB[n]; } pTime = iTime(NULL,TimeFrame,mBars-y-1); } for(n = 11; n<= 59; n++) { double beta = MathCos(4*pi/(n+1)); double gamma = 1.0/MathCos(8*pi*delta/(n+1)); double alpha = gamma - MathSqrt(gamma*gamma - 1); Q[n] = ((n+1)/4/pi)*(SmoothHP[y] - SmoothHP[y-1]); I[n] = SmoothHP[y]; Real[n] = 0.5*(1 - alpha)*(I[n] - OlderI[n]) + beta*(1 + alpha)*OldReal[n] - alpha*OlderReal[n]; Imag[n] = 0.5*(1 - alpha)*(Q[n] - OlderQ[n]) + beta*(1 + alpha)*OldImag[n] - alpha*OlderImag[n]; Ampl[n] = (Real[n]*Real[n] + Imag[n]*Imag[n]); } MaxAmpl = Ampl[11]; for(n = 11; n<= 59; n++) if(Ampl[n] > MaxAmpl) {MaxAmpl = Ampl[n]; int nmax = n;} for(n = 11; n<= 59; n++) { if(MaxAmpl != 0) if (Ampl[n] / MaxAmpl > 0) double dB = -10.0*MathLog(0.01/(1 - 0.99*Ampl[n]/MaxAmpl))/MathLog(10.0); DB[n] = 0.33*dB + 0.67*OldDB[n]; if(DB[n] > 20) DB[n] = 20; } double Num = 0; double Denom = 0; for(n = 11; n<= 59; n++) { if(DB[n] <= 6) { Num = Num + (n+1)*(20 - DB[n]); Denom = Denom + (20 - DB[n]); } if(Denom != 0) DC[y] = 0.5*Num / Denom; else DC[y] = DC[y-1]; } mDomCyc[y] = Median(DC, 5, y); } DomCyc[mBars-y-1] = mDomCyc[y]; mcnt_bars = mBars-1; } WindowRedraw(); return(0); } double Median(double price[],int per,int bar) { double array[]; ArrayResize(array,per); for(int i = 0; i < per;i++) array[i] = price[bar-i]; ArraySort(array); int num = MathRound((per-1)/2); if(MathMod(per,2)>0) double median = array[num]; else median = 0.5*(array[num]+array[num+1]); return(median); }
@virux84
virux84
03 Apr 2013, 20:34
How to get current hour time.
Thank you
@virux84