MagicPi 發表於 13-2-28 22:59
最下面那個是什麼=口=!?
還是只是上了馬賽克
程式碼
{ Corona Chart Cycle Period
written by John F. Ehlers copyright (c) 2008
The spectral content of the data are measured in a bank of contiguous
filters as described in "Measuring Cycle Periods" in the March 2008 issue
of Stocks & Commodities Magazine. The filter having the strongest output
is selected as the current dominant cycle period. The cycle period is
measured as the number of bars contained in one full cycle period.
}
Inputs:
Price((H+L)/2),
LineR(255),
LineG(255),
LineB(0),
FuzzR(255),
FuzzG(0),
FuzzB(0),
ShowDC(True);
Vars:
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);
Arrays:
myI[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);
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]);
myI[N] = SmoothHP;
Real[N] = .5*(1 - alpha)*(myI[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] = myI[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;
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 ShowDC = True Then Plot1(DomCyc, "DC", RGB(LineR, LineG, LineB), 0, 2);
For N = 12 to 60 Begin
IF DB[N] <= 10 THEN Begin
Color1 = LineR + DB[N]*(FuzzR - LineR) / 10;
Color2 = LineG + DB[N]*(FuzzG - LineG) / 10;
Color3 = LineB + DB[N]*(FuzzB - LineB) / 10;
END;
IF DB[N] > 10 THEN Begin
Color1 = FuzzR*(2 - DB[N] / 10);
Color2 = FuzzG*(2 - DB[N] / 10);
Color3 = FuzzB*(2 - DB[N] / 10);
END;
If N = 12 Then Plot12(N/2, "S12", RGB(Color1, Color2, Color3),0,5);
If N = 13 Then Plot13(N/2, "S13", RGB(Color1, Color2, Color3),0,5);
If N = 14 Then Plot14(N/2, "S14", RGB(Color1, Color2, Color3),0,5);
If N = 15 Then Plot15(N/2, "S15", RGB(Color1, Color2, Color3),0,5);
If N = 16 Then Plot16(N/2, "S16", RGB(Color1, Color2, Color3),0,5);
If N = 17 Then Plot17(N/2, "S17", RGB(Color1, Color2, Color3),0,5);
If N = 18 Then Plot18(N/2, "S18", RGB(Color1, Color2, Color3),0,5);
If N = 19 Then Plot19(N/2, "S19", RGB(Color1, Color2, Color3),0,5);
If N = 20 Then Plot20(N/2, "S20", RGB(Color1, Color2, Color3),0,5);
If N = 21 Then Plot21(N/2, "S21", RGB(Color1, Color2, Color3),0,5);
If N = 22 Then Plot22(N/2, "S22", RGB(Color1, Color2, Color3),0,5);
If N = 23 Then Plot23(N/2, "S23", RGB(Color1, Color2, Color3),0,5);
If N = 24 Then Plot24(N/2, "S24", RGB(Color1, Color2, Color3),0,5);
If N = 25 Then Plot25(N/2, "S25", RGB(Color1, Color2, Color3),0,5);
If N = 26 Then Plot26(N/2, "S26", RGB(Color1, Color2, Color3),0,5);
If N = 27 Then Plot27(N/2, "S27", RGB(Color1, Color2, Color3),0,5);
If N = 28 Then Plot28(N/2, "S28", RGB(Color1, Color2, Color3),0,5);
If N = 29 Then Plot29(N/2, "S29", RGB(Color1, Color2, Color3),0,5);
If N = 30 Then Plot30(N/2, "S30", RGB(Color1, Color2, Color3),0,5);
If N = 31 Then Plot31(N/2, "S31", RGB(Color1, Color2, Color3),0,5);
If N = 32 Then Plot32(N/2, "S32", RGB(Color1, Color2, Color3),0,5);
If N = 33 Then Plot33(N/2, "S33", RGB(Color1, Color2, Color3),0,5);
If N = 34 Then Plot34(N/2, "S34", RGB(Color1, Color2, Color3),0,5);
If N = 35 Then Plot35(N/2, "S35", RGB(Color1, Color2, Color3),0,5);
If N = 36 Then Plot36(N/2, "S36", RGB(Color1, Color2, Color3),0,5);
If N = 37 Then Plot37(N/2, "S37", RGB(Color1, Color2, Color3),0,5);
If N = 38 Then Plot38(N/2, "S38", RGB(Color1, Color2, Color3),0,5);
If N = 39 Then Plot39(N/2, "S39", RGB(Color1, Color2, Color3),0,5);
If N = 40 Then Plot40(N/2, "S40", RGB(Color1, Color2, Color3),0,5);
If N = 41 Then Plot41(N/2, "S41", RGB(Color1, Color2, Color3),0,5);
If N = 42 Then Plot42(N/2, "S42", RGB(Color1, Color2, Color3),0,5);
If N = 43 Then Plot43(N/2, "S43", RGB(Color1, Color2, Color3),0,5);
If N = 44 Then Plot44(N/2, "S44", RGB(Color1, Color2, Color3),0,5);
If N = 45 Then Plot45(N/2, "S45", RGB(Color1, Color2, Color3),0,5);
If N = 46 Then Plot46(N/2, "S46", RGB(Color1, Color2, Color3),0,5);
If N = 47 Then Plot47(N/2, "S47", RGB(Color1, Color2, Color3),0,5);
If N = 48 Then Plot48(N/2, "S48", RGB(Color1, Color2, Color3),0,5);
If N = 49 Then Plot49(N/2, "S49", RGB(Color1, Color2, Color3),0,5);
If N = 50 Then Plot50(N/2, "S50", RGB(Color1, Color2, Color3),0,5);
If N = 51 Then Plot51(N/2, "S51", RGB(Color1, Color2, Color3),0,5);
If N = 52 Then Plot52(N/2, "S52", RGB(Color1, Color2, Color3),0,5);
If N = 53 Then Plot53(N/2, "S53", RGB(Color1, Color2, Color3),0,5);
If N = 54 Then Plot54(N/2, "S54", RGB(Color1, Color2, Color3),0,5);
If N = 55 Then Plot55(N/2, "S55", RGB(Color1, Color2, Color3),0,5);
If N = 56 Then Plot56(N/2, "S56", RGB(Color1, Color2, Color3),0,5);
If N = 57 Then Plot57(N/2, "S57", RGB(Color1, Color2, Color3),0,5);
If N = 58 Then Plot58(N/2, "S58", RGB(Color1, Color2, Color3),0,5);
If N = 59 Then Plot59(N/2, "S59", RGB(Color1, Color2, Color3),0,5);
If N = 60 Then Plot60(N/2, "S50", RGB(Color1, Color2, Color3),0,5);
End;
|