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

[trader'stip]_corona_snr

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




Inputs: 
 LineR(220),
 LineG(255),
 LineB(255),
 FuzzR(0),
 FuzzG(190),
 FuzzB(190);

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),
 Avg(0),
 Signal(0),
 Noise(0),
 SNR(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 {
 Avg = 0.1*Price + 0.9*Avg[1];
 If Avg <> 0 and MaxAmpl > 0 Then Signal = 0.2*SquareRoot(MaxAmpl) + 0.9*Signal[1];
 If Avg <> 0 and CurrentBar > 5 Then Noise = 0.1*Median((H-L), 5) + 0.9*Noise[1];
 If Signal <> 0 and Noise <> 0 Then SNR = 20*Log(Signal / Noise) / Log(10) + 3.5;
 IF SNR < 1 Then SNR = 0;
 If SNR > 11 Then SNR = 10;
 SNR = 0.1*SNR;
}
Width = -0.4*SNR + 0.2;
If SNR > 0.5 then Width = 0;

For N = 1 to 50 {
 Raster[N] = 20;
 If N < Round(50*SNR,0) Then Raster[N] = 0.5*(Power((20*SNR  - 0.4*N)/ Width, 0.8) + OldRaster[N]);
 If N > Round(50*SNR, 0) and (0.4*N - 20*SNR) / Width > 1 Then Raster[N] = 0.5*(Power((-20*SNR + 0.4*N)/ Width, 0.8) + OldRaster[N]) ;
 If N == Round(50*SNR,0) Then Raster[N] = 0 + 0.5*OldRaster[N];
 If Raster[N] < 0 Then Raster[N] = 0;
 If Raster[N] > 20 Then Raster[N] = 20;
 If SNR > 0.5 then Raster[N] = 20;
}

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






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

[trader'stip]_corona_swing_psn  (0) 2015.01.27
[trader'stip]_corona_cycleperiod  (0) 2015.01.27
마켓프로파일 지표  (0) 2015.01.23

댓글