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

[trader'stip]_corona_swing_psn

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




/* Corona Chart Swing Position
 written by John F. Ehlers copyright (c) 2008

 The swing position indicator shows the phasing of the data within the
 dominant cycle.  A value of -5 means the cycle is at its valley.  A value
 of +5 means the cycle is at its peak.  In a pure cycle the Swing Position
 will trace out the shape of a sine wave.
*/

Inputs: 
 LineR(180),
 LineG(255),
 LineB(210),
 FuzzR(0),
 FuzzG(172),
 FuzzB(64);

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),
 gamma2(0),
 alpha2(0),
 beta2(0),
 delta2(.1),
 BP2(0),
 Q2(0),
 Lead60(0),
 HL(0),
 LL(0),
 count(0),
 Psn(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 = 0.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 = -0.015*CurrentBar + 0.5;
If delta < 0.1 then delta = 0.1;

If CurrentBar > 12 Then {
 For N = 12 to 60 { 
  beta = Cosine(720 / N);
  gamma = 1 / Cosine(1440*delta / N);
  alpha = gamma - SquareRoot(gamma*gamma - 1);
  Q[N] = (0.5*N / 6.28318)*(SmoothHP - SmoothHP[1]);
  II[N] = SmoothHP;
  Real[N] = 0.5*(1 - alpha)*(II[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]);
 }
}
For N = 12 to 60 {
 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];
}

For N = 1 to 50 {
 OldRaster[N] = Raster[N];
}

MaxAmpl = Ampl[12];
For N = 12 to 60 {
 If Ampl[N] > MaxAmpl then MaxAmpl = Ampl[N];
}

For N = 12 to 60 {
    If MaxAmpl <> 0 AND (Ampl[N] / MaxAmpl) > 0 Then DB[N] = -10*Log(0.01 / (1 - 0.99*Ampl[N] / MaxAmpl)) / Log(10);
 DB[N] = 0.33*DB[N] + 0.67*OldDB[N];
 If DB[N] > 20 then DB[N] = 20;
}
Num = 0;
Denom = 0;
For N = 12 to 60 {
 If DB[N] <= 6 Then {
  Num = Num + N*(20 - DB[N]);
  Denom = Denom + (20 - DB[N]);
 }
 If Denom <> 0 Then DC = 0.5*Num / Denom;
}
DomCyc = Median(DC, 5);
If DomCyc < 6 Then DomCyc = 6;

if CurrentBar > 1 then {
 beta2 = Cosine(360 / DomCyc);
 gamma2 = 1 / Cosine(720*delta2 / DomCyc);
 alpha2 = gamma2 - SquareRoot(gamma2*gamma2 - 1);
 BP2 = 0.5*(1 - alpha2)*(Price - Price[2]) + beta2*(1 + alpha2)*BP2[1] - alpha2*BP2[2];
 Q2 = (DomCyc / 6.28318)*(BP2 - BP2[1]);
 Lead60 = 0.5*BP2 + 0.866*Q2;
}
HL = Lead60;
LL = Lead60;
For count = 0 to 50 {
 If Lead60[count] > HL then HL = Lead60[count];
 If Lead60[count] < LL then LL = Lead60[count];
}
Psn = (Lead60 - LL) / (Hl - LL);

HL = Psn;
LL = Psn;
For count = 0 to 20 {
 If Psn[count] > HL then HL = Psn[count];
 If Psn[count] < LL then LL = Psn[count];
}
If HL - LL > 0.85 Then Width = 0.01; Else Width = 0.15*(HL - LL); 

For N = 1 to 50 {
 Raster[N] = 20;
 If N < Round(50*Psn,0) Then Raster[N] = 0.5*(Power((20*Psn  - 0.4*N)/ Width, 0.95) + 0.5*OldRaster[N]);
 If N > Round(50*Psn,0) Then Raster[N] = 0.5*(Power((-20*Psn + 0.4*N)/ Width, 0.95) + 0.5*OldRaster[N]);
 If N == Round(50*Psn,0) Then Raster[N] = 0.5*OldRaster[N];
 //If Date = 20080401 Then Print(Date);
 If Raster[N] < 0 Then Raster[N] = 0;
 If Raster[N] > 20 Then Raster[N] = 20;
 If HL - LL > 0.8 then Raster[N] = 20;
 OldRaster[N] = Raster[N];
}

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

'∎ 매매의 기술 [ K ] > 지표편집' 카테고리의 다른 글

[trader'stip]_corona_trendvigor  (0) 2015.01.27
[trader'stip]_corona_snr  (0) 2015.01.27
[trader'stip]_corona_cycleperiod  (0) 2015.01.27

댓글