Type : Indicator, Name : ## Retr Indicator
vars:
STL(0),
ITL(0),
LTL(0),
HOFF(0),
SOFF(0),
IOFF(0),
LTOFF(0),
Phase(1),
mtl(0),
momsig(0),
mom(0),
HT(0),
HTA(0),
price(0),
harmonic(0),
ST(0),
STA(0),
IT(0),
ITA(0),
SUM(0),
ERR(0),
ERRSUM(0),
ERRSIG(0),
TC(0),
TCSIG(0),
ERRNUM(0),
MOMNUM(0),
TCNUM(0),
String2(""); price=c;
{Calculate Lengths}
harmonic=6;
STL= 11; {11}
ITL= 21; {21}
LTL= 41; {41}
HOFF=3; {3}
SOFF=5; {5}
IOFF=10; {10}
LTOFF=20; {20}
{Cycle Momentum}
value2 = average(price,STL) - average(price,Harmonic)[HOFF];
value3 = average(price,ITL) - average(price,STL)[SOFF];
value12 = average(price,LTL)-average(price,ITL)[IOFF];
momsig = value2 + value3 + value12; {Signal Line}
value5= ((summation(price,harmonic-1) +
derivativema(price,harmonic))/harmonic);
value6= ((summation(price,STL-1) + derivativema(price,STL))/STL);
value7= ((summation(price,ITL-1) + derivativema(price,ITL))/ITL);
value13=((summation(avgprice,LTL-1) + derivativema(price,LTL))/LTL);
value9 = value6 - value5[HOFF];
value10=value7 - value6[SOFF];
value14=value13 - value7[IOFF];
mom = value9 + value10 + value14;
{ harmonic =6 was 5 may use harmonic -1 }
HT=
sine((summation(price,(harmonic-1))+derivativema(price,harmonic))/harmonic)
+
cosine((summation(price,(harmonic-1))+derivativema(price,harmonic))/harmonic);
HTA= sine(average(price,harmonic)) +cosine(average(price,harmonic));
ST= sine((summation(price,(STL-1))+derivativema(price,STL))/ STL) +
cosine((summation(Price,(STL-1))+derivativema(Price,STL))/STL);
STA = sine(average(price,STL)) + cosine(average(price,STL));
IT= sine((summation(price,(ITL-1))+derivativema(c,ITL))/ITL) +
cosine((summation(price,(ITL-1))+derivativema(Price,ITL))/ITL);
ITA=sine(average(price,ITL))+ cosine(average(price,ITL));
Sum= HT+ST+IT; {Est in Cyc Estimator/ Cycle Est Err = Sum - Err }
Err =HTA + STA +ITA;
{phase detect}
{phase detect}
phase=1;
value7=average(medianprice,3);
if value7>value7[1] and sum<sum[1] then begin
phase=-1;
end;
if value7<value7[1] and sum>sum[1] then begin
phase=-1;
end;
ErrSum = (Sum - Err)*phase; { ERROR OF THE CYCLE}
ErrSig=average(ErrSum,SOFF); { ERROR SIGNAL LINE}
{Trend Catcher}
value68=( (summation(price,(harmonic-1)) + derivativema(price,harmonic))
/ harmonic );
value69=( (summation(avgprice,(LTL-1)) + derivativema(price,LTL)) / LTL
);
value70 = value68-value69; { EST W Der}
value71 = average(value70,Harmonic);
TC =value70;
TCSig=value71;
{Begin Counting Bars}
If ErrSum > 0 then begin
if Errsum < ErrSum[1] and ErrSum < ErrSig then ErrNum=1;
If ErrSum <ErrSum[1] and ErrSum >ErrSig then ErrNum=2;
If ErrSum>ErrSum[1] and ErrSum<ErrSig then ErrNum=2;
If ErrSum > ErrSum[1] and ErrSum> ErrSig then ErrNum=3;
End;
If ErrSum < 0 then begin
if Errsum > ErrSum[1] and ErrSum > ErrSig then ErrNum=-1;
If ErrSum <ErrSum[1] and ErrSum >ErrSig then ErrNum=-2;
If ErrSum>ErrSum[1] and ErrSum<ErrSig then ErrNum=-2;
If ErrSum < ErrSum[1] and ErrSum< ErrSig then ErrNum=-3;
End;
If Mom > 0 THEN begin
if mom < mom[1] and mom < momsig then momNum=1;
If mom <mom[1] and mom >momsig then momNum=2;
If mom>mom[1] and mom<momsig then momNum=2;
If mom > mom[1] and mom> momSig then momNum=3;
End;
If mom < 0 then begin
if mom > mom[1] and mom > momSig then momNum=-1;
If mom <mom[1] and mom >momSig then momNum=-2;
If mom>mom[1] and mom<momSig then momNum=-2;
If mom < mom[1] and mom< momSig then momNum=-3;
End;
If TC > 0 THEN begin
if TC < TC[1] and TC < TCsig then TCNum=1;
If TC <TC[1] and TC >TCsig then TCNum=2;
If TC>TC[1] and TC<TCsig then TCNum=2;
If TC > TC[1] and TC> TCSig then TCNum=3;
End;
If TC < 0 then begin
if TC > TC[1] and TC > TCSig then TCNum=-1;
If TC <TC[1] and TC >TCSig then TCNum=-2;
If TC>TC[1] and TC<TCSig then TCNum=-2;
If TC < TC[1] and TC< TCSig then TCNum=-3;
End;
value42= ErrNum + MomNum+TCNum;
If value42=5 then begin
If ErrSum > 0 then begin
If TC < 0 THEN begin { + 5 Yellow}
Plot1(l-1 point,"+5Y");
end;
if TC>0 then begin {+5G}
plot2(l-1 point,"+5G");
End;
End;
end;
If value42=-5 then begin
If ErrSum < 0 then begin
If TC > 0 THEN begin { - 5 Yellow}
Plot3(h+1 point,"-5Y");
end;
if TC<0 then begin {-5R}
plot4(h+1 point,"-5R");
end;
End;
end;
|