본문 바로가기
∎ 매매의 기술 [ K ]/지표편집

[trader'stip]_corona_trendvigor

by 케이님[K] 2015. 1. 27.






/* Corona Chart Trend Vigor
 written by John F. Ehlers copyright(c) 2008

 Once the dominant cycle period is known, the instantaneous trend
 is just the momentum across the full cycle period.  This measurement
 is invariant with the position within the cycle.  The trend slope
 is the same whether measured from cycle peak to cycle peak or cycle
 valley to cycle valley.  The trend slope is normalized to the amplitude
 of the dominant cycle.  A value of +2 means the trend slope is twice the
 dominant cycle amplitude, and therefore cautions you not to trade against
 the upslope.  Similarly, a value of -2 means the trend slope is down and
 therefore cautions you not to buy against the downslope.
*/

Inputs: 
 LineR(64),
 LineG(128),
 LineB(255),
 FuzzR(0),
 FuzzG(0),
 FuzzB(255);

Vars:
 Price(0),
 delta(0.1), 
 gamma(0),
 alpha(0),
 beta(0),
 N(0),
 Period(0),
 MaxAmpl(0),
 Num(0),
 Denom(0),
 DC(0),
 DomCyc(0),
 Color1(0),
 Color2(0),
 Color3(0),
 alpha1(0),
 HP(0),
 SmoothHP(0),
 delta1(.1),
 gamma1(0),
 alpha2(0),
 beta1(0),
 IP(0),
 Q1(0),
 Ampl2(0),
 Trend(0),
 Ratio(0),
 TV(0),
 Width(0);

Arrays:
 II[60](0),
 OldI[60](0),
 OlderI[60](0),
 Q[60](0),
 OldQ[60](0),
 OlderQ[60](0),
 Real[60](0),
 OldReal[60](0),
 OlderReal[60](0),
 Imag[60](0),
 OldImag[60](0),
 OlderImag[60](0),
 Ampl[60](0),
 OldAmpl[60](0),
 DB[60](0),
 OldDB[60](0),
 Raster[50](0),
 OldRaster[50](0);

if CurrentBar > 1 then {
    price = (H+L)/2;
 alpha1 = (1 - Sine (360 / 30)) / Cosine(360 / 30);
 HP = .5*(1 + alpha1)*(Price - Price[1]) + alpha1*HP[1];
 SmoothHP = (HP + 2*HP[1] + 3*HP[2] + 3*HP[3] + 2*HP[4] + HP[5]) / 12;
 IF CurrentBar < 7 Then SmoothHP = Price - Price[1];
 IF CurrentBar == 1 THEN SmoothHP = 0;
}
delta = -.015*CurrentBar + .5;
If delta < .1 then delta = .1;

If CurrentBar > 12 Then Begin
 For N = 12 to 60 Begin 
  beta = Cosine(720 / N);
  gamma = 1 / Cosine(1440*delta / N);
  alpha = gamma - SquareRoot(gamma*gamma - 1);
  Q[N] = (.5*N / 6.28318)*(SmoothHP - SmoothHP[1]);
  II[N] = SmoothHP;
  Real[N] = .5*(1 - alpha)*(II[N] - OlderI[N]) + beta*(1 + alpha)*OldReal[N] - alpha*OlderReal[N];
  Imag[N] = .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]);
 End;
End;
For N = 12 to 60 Begin
 OlderI[N] = OldI[N];
 OldI[N] = II[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];
 OldAmpl[N] = Ampl[N];
 OldDB[N] = DB[N];
End;

For N = 1 to 50 Begin
 OldRaster[N] = Raster[N];
End;

MaxAmpl = Ampl[12];
For N = 12 to 60 Begin
 If Ampl[N] > MaxAmpl then MaxAmpl = Ampl[N];
End;

For N = 12 to 60 Begin
    If MaxAmpl <> 0 AND (Ampl[N] / MaxAmpl) > 0 Then DB[N] = -10*Log(.01 / (1 - .99*Ampl[N] / MaxAmpl)) / Log(10);
 DB[N] = .33*DB[N] + .67*OldDB[N];
 If DB[N] > 20 then DB[N] = 20;
End;
Num = 0;
Denom = 0;
For N = 12 to 60 Begin
 If DB[N] <= 6 Then Begin
  Num = Num + N*(20 - DB[N]);
  Denom = Denom + (20 - DB[N]);
 End;
 If Denom <> 0 Then DC = .5*Num / Denom;
End;
DomCyc = Median(DC, 5);
If DomCyc < 6 Then DomCyc = 6;

if Currentbar > 1 then {
 //Filter Bandpass component
 beta1 = Cosine(360 / DomCyc);
 gamma1 = 1 / Cosine(720*delta1 / DomCyc);
 alpha2 = gamma1 - SquareRoot(gamma1*gamma1 - 1);
 IP = .5*(1 - alpha2)*(Price - Price[2]) + beta1*(1 + alpha2)*IP[1] - alpha2*IP[2];
 
 //Quadrature component is derivative of InPhase component divided by omega
 Q1 = (Domcyc / 6.28318)*(IP - IP[1]);
 
 //Pythagorean theorem to establish cycle amplitude
 Ampl2 = SquareRoot(IP*IP + Q1*Q1);
 
 //Trend amplitude taken over the cycle period
 Trend = Price - Price[DomCyc - 1];
 If Trend <> 0 and Ampl2 <> 0 Then Ratio = .33*Trend / Ampl2 + .67*Ratio[1];
 If Ratio > 10 then Ratio = 10;
 If Ratio < -10 then Ratio = -10;
 TV = .05*(Ratio + 10);
}

If TV < .3 or TV > .7 Then Width = .01;
If TV >= .3 and TV < .5 Then Width = TV - .3;
If TV > .5 and TV <= .7 Then Width = -TV + .7; 

For N = 1 to 50 Begin
 Raster[N] = 20;
 If N < Round(50*TV,0) Then Raster[N] = .8*(Power((20*TV  - .4*N)/ Width, .85) + .2*OldRaster[N]);
 If N > Round(50*TV,0) Then Raster[N] = .8*(Power((-20*TV + .4*N)/ Width, .85) + .2*OldRaster[N]) ;
 If N == Round(50*TV,0) Then Raster[N] = 0 + .5*OldRaster[N];
 If Raster[N] < 0 Then Raster[N] = 0;
 If Raster[N] > 20 Or TV < .3 Or TV > .7 Then Raster[N] = 20;
End;

Plot1(20*TV-10, "S51", RGB(LineR, LineG, LineB),0,2);
Plot51(20*TV-10, "S51", RGB(LineR, LineG, LineB),0,2);

For N = 1 to 50 {

    IF Raster[N] <= 10 THEN {
        Color1 = LineR + Raster[N]*(FuzzR - LineR) / 10;
        Color2 = LineG + Raster[N]*(FuzzG - LineG) / 10;
  Color3 = LineB + Raster[N]*(FuzzB - LineB) / 10;
    }
    IF Raster[N] > 10 THEN {
        Color1 = FuzzR*(2 - Raster[N] / 10);
        Color2 = FuzzG*(2 - Raster[N] / 10);
  Color3 = FuzzB*(2 - Raster[N] / 10);

    }

 //If N = 1 Then Plot1(N, "S1", RGB(Color1, Color2, Color3),Color3,5);
 If N == 2 Then Plot50(.4*N-10, "S2", RGB(Color1, Color2, Color3),0,5);
 If N == 3 Then Plot49(.4*N-10, "S3", RGB(Color1, Color2, Color3),0,5);
 If N == 4 Then Plot48(.4*N-10, "S4", RGB(Color1, Color2, Color3),0,5);
 If N == 5 Then Plot47(.4*N-10, "S5", RGB(Color1, Color2, Color3),0,5);
 If N == 6 Then Plot46(.4*N-10, "S6", RGB(Color1, Color2, Color3),0,5);
 If N == 7 Then Plot45(.4*N-10, "S7", RGB(Color1, Color2, Color3),0,5);
 If N == 8 Then Plot44(.4*N-10, "S8", RGB(Color1, Color2, Color3),0,5);
 If N == 9 Then Plot43(.4*N-10, "S9", RGB(Color1, Color2, Color3),0,5);
 If N == 10 Then Plot42(.4*N-10, "S10", RGB(Color1, Color2, Color3),0,5);
 If N == 11 Then Plot41(.4*N-10, "S11", RGB(Color1, Color2, Color3),0,5);
 If N == 12 Then Plot40(.4*N-10, "S12", RGB(Color1, Color2, Color3),0,5);
 If N == 13 Then Plot39(.4*N-10, "S13", RGB(Color1, Color2, Color3),0,5);
 If N == 14 Then Plot38(.4*N-10, "S14", RGB(Color1, Color2, Color3),0,5);
 If N == 15 Then Plot37(.4*N-10, "S15", RGB(Color1, Color2, Color3),0,5);
 If N == 16 Then Plot36(.4*N-10, "S16", RGB(Color1, Color2, Color3),0,5);
 If N == 17 Then Plot35(.4*N-10, "S17", RGB(Color1, Color2, Color3),0,5);
 If N == 18 Then Plot34(.4*N-10, "S18", RGB(Color1, Color2, Color3),0,5);
 If N == 19 Then Plot33(.4*N-10, "S19", RGB(Color1, Color2, Color3),0,5);
 If N == 20 Then Plot32(.4*N-10, "S20", RGB(Color1, Color2, Color3),0,5);
 If N == 21 Then Plot31(.4*N-10, "S21", RGB(Color1, Color2, Color3),0,5);
 If N == 22 Then Plot30(.4*N-10, "S22", RGB(Color1, Color2, Color3),0,5);
 If N == 23 Then Plot29(.4*N-10, "S23", RGB(Color1, Color2, Color3),0,5);
 If N == 24 Then Plot28(.4*N-10, "S24", RGB(Color1, Color2, Color3),0,5);
 If N == 25 Then Plot27(.4*N-10, "S25", RGB(Color1, Color2, Color3),0,5);
 If N == 26 Then Plot26(.4*N-10, "S26", RGB(Color1, Color2, Color3),0,5);
 If N == 27 Then Plot25(.4*N-10, "S27", RGB(Color1, Color2, Color3),0,5);
 If N == 28 Then Plot24(.4*N-10, "S28", RGB(Color1, Color2, Color3),0,5);
 If N == 29 Then Plot23(.4*N-10, "S29", RGB(Color1, Color2, Color3),0,5);
 If N == 30 Then Plot22(.4*N-10, "S30", RGB(Color1, Color2, Color3),0,5);
 If N == 31 Then Plot21(.4*N-10, "S31", RGB(Color1, Color2, Color3),0,5);
 If N == 32 Then Plot20(.4*N-10, "S32", RGB(Color1, Color2, Color3),0,5);
 If N == 33 Then Plot19(.4*N-10, "S33", RGB(Color1, Color2, Color3),0,5);
 If N == 34 Then Plot18(.4*N-10, "S34", RGB(Color1, Color2, Color3),0,5);
 If N == 35 Then Plot17(.4*N-10, "S35", RGB(Color1, Color2, Color3),0,5);
 If N == 36 Then Plot16(.4*N-10, "S36", RGB(Color1, Color2, Color3),0,5);
 If N == 37 Then Plot15(.4*N-10, "S37", RGB(Color1, Color2, Color3),0,5);
 If N == 38 Then Plot14(.4*N-10, "S38", RGB(Color1, Color2, Color3),0,5);
 If N == 39 Then Plot13(.4*N-10, "S39", RGB(Color1, Color2, Color3),0,5);
 If N == 40 Then Plot12(.4*N-10, "S40", RGB(Color1, Color2, Color3),0,5);
 If N == 41 Then Plot11(.4*N-10, "S41", RGB(Color1, Color2, Color3),0,5);
 If N == 42 Then Plot10(.4*N-10, "S42", RGB(Color1, Color2, Color3),0,5);
 If N == 43 Then Plot9(.4*N-10, "S43", RGB(Color1, Color2, Color3),0,5);
 If N == 44 Then Plot8(.4*N-10, "S44", RGB(Color1, Color2, Color3),0,5);
 If N == 45 Then Plot7(.4*N-10, "S45", RGB(Color1, Color2, Color3),0,5);
 If N == 46 Then Plot6(.4*N-10, "S46", RGB(Color1, Color2, Color3),0,5);
 If N == 47 Then Plot5(.4*N-10, "S47", RGB(Color1, Color2, Color3),0,5);
 If N == 48 Then Plot4(.4*N-10, "S48", RGB(Color1, Color2, Color3),0,5);
 If N == 49 Then Plot3(.4*N-10, "S49", RGB(Color1, Color2, Color3),0,5);
 If N == 50 Then Plot2(.4*N-10, "S50", RGB(Color1, Color2, Color3),0,5);
}


댓글