For any of those interested in tinkering with Hurst Channels, am
attaching code I had recieved from group member Jason Hart. This code
was written by group member going by the nickname "Ace".

I was not able to make much use of it. The reason was -  the values of
the channels, current and in the immediate past  i.e. the projection
zone, were not constant. Since the values of the projections changed
everyday I had no way of making any meaningful use of it ( I was
basically looking for what Hurst called "Edge Band" Trades). If my
understanding was incorrect and anyone can make sense of them,  please
be kind enough to share your insights with the rest of us.


Rakesh


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 
_SECTION_BEGIN("Hurst Channels");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} O %g, H %g, L %g, C %g,  (%.1f%%) {{VALUES}}", O, H, L, C,  SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorRed ), styleNoTitle | ParamStyle("Style", styleBar, maskPrice ) ); 


//------------------------------------------------------

// -------------------- HURST DE ---------------------

// --- by Ace

//------------------------------------------------------

// Hurst DE based on Centered SMA's with a forward projected

// curve based on A parabolic fit

//------------------------------------------------------

// SET THE S/T and I/T PERIODS




p1=Param("1) S/T DE Period",8,1,373,1);

p2=Param("2) I/T DE Period",16,1,373,1);

p3=Param("3) L/T DE Period",32,1,373,1);

//------------------------------------------------------

// Moving Averages and Lags

//------------------------------------------------------

p0=p1/2;

IIf(p1/2!=round(p1/2),p0=p0-1,p0=p0);

Ave0=WMA(C,p0);//MA(C,p0);

Ave1=WMA(C,p1);//Ma(C,p1);

Ave2=WMA(C,p2);//MA(C,p2);

Ave3=WMA(C,p3);//Ma(C,p3);

Lag0=(p0+1)/2;

Lag1=(p1+1)/2;

Lag2=(p2+1)/2;

Lag3=(p3+1)/2;

//------------------------------------------------------

// Center the MA's

//------------------------------------------------------

cma0=Ref(Ave0,Lag0);

cma1=Ref(Ave1,Lag1);

cma2=Ref(Ave2,Lag2);

cma3=Ref(Ave3,Lag3);

//------------------------------------------------------

// Percentage Based Widths

//------------------------------------------------------

k=3;

dp1=LastValue(Ref(StDev( (Close-cma1)/cma1, k*p1 ),(p1+1)/2-1));

dp2=LastValue(Ref(StDev( (Close-cma2)/cma2, k*p2 ),(p2+1)/2-1));

dp3=LastValue(Ref(StDev( (Close-cma3)/cma3, k*p3 ),(p3+1)/2-1));

//------------------------------------------------------


// Calculate a Parabolic Extension for the S/T DE

//------------------------------------------------------

tn=round(p1/6);

fillforward=BarIndex() >= LastValue( BarIndex() )-Lag1;

t=BarIndex()-Ref(BarIndex(),Lag1)+Lag1;

// Get Constants for the Parabolic fit equation

Sm=LastValue(Ref(Ave1,-2*tn));

// This coordinate is actually t=0

So=LastValue(Ref(Ave1,-tn));

Sp=LastValue(Ave1);

// Calculate coeff's for the parabola

Ak=So;

Bk=(Sp-Sm)/2/tn;

Ck=(Sp+Sm-2*So)/2/tn^2;

parabfit1=Ak+Bk*t+Ck*t^2;

dy1=LastValue(Ave1)-Ak;

cma1=IIf(fillforward,parabfit1+dy1,cma1);

//------------------------------------------------------

// Calculate a Parabolic Extension for the I/T DE

//------------------------------------------------------

tn=round(p2/6);

fillforward=BarIndex() >= LastValue( BarIndex() )-Lag2;

t=BarIndex()-Ref(BarIndex(),Lag2)+Lag2;

// Get Constants for the Parabolic fit equation

Sm=LastValue(Ref(Ave2,-2*tn));

// This coordinate is actually t=0

So=LastValue(Ref(Ave2,-tn));

Sp=LastValue(Ave2);

// Calculate coeff's for the parabola

Ak=So;

Bk=(Sp-Sm)/2/tn;

Ck=(Sp+Sm-2*So)/2/tn^2;

parabfit2=Ak+Bk*t+Ck*t^2;

dy2=LastValue(Ave2)-Ak;

cma2=IIf(fillforward,parabfit2+dy2,cma2);

//------------------------------------------------------

// Calculate a Parabolic Extension for the L/T DE

//------------------------------------------------------

tn=round(p3/6);

fillforward=BarIndex() >= LastValue( BarIndex() )-Lag3;

t=BarIndex()-Ref(BarIndex(),Lag3)+Lag3;

// Get Constants for the Parabolic fit equation

Sm=LastValue(Ref(Ave3,-2*tn));

// This coordinate is actually t=0

So=LastValue(Ref(Ave3,-tn));

Sp=LastValue(Ave3);

// Calculate coeff's for the parabola

Ak=So;

Bk=(Sp-Sm)/2/tn;

Ck=(Sp+Sm-2*So)/2/tn^2;

parabfit3=Ak+Bk*t+Ck*t^2;

dy3=LastValue(Ave3)-Ak;

cma3=IIf(fillforward,parabfit3+dy3,cma3);

//------------------------------------------------------

// Fast MA with parabolic fit - p1/2 period

//------------------------------------------------------

tn=round(p0/6);

fillforward=BarIndex() >= LastValue( BarIndex() )-Lag0;

t=BarIndex()-Ref(BarIndex(),Lag0)+Lag0;

// Get Constants for the Parabolic fit equation

Sm=LastValue(Ref(Ave0,-2*tn));

// This coordinate is actually t=0

So=LastValue(Ref(Ave0,-tn));

Sp=LastValue(Ave0);

// Calculate coeff's for the parabola

Ak=So;

Bk=(Sp-Sm)/2/tn;

Ck=(Sp+Sm-2*So)/2/tn^2;

parabfit0=Ak+Bk*t+Ck*t^2;

dy0=LastValue(Ave0)-Ak;

cma0=IIf(fillforward,parabfit0+dy0,cma0);

//------------------------------------------------------


// Write the selected bar lengths to the window

//------------------------------------------------------

"HURST DOMINANCY ENVELOPES";

"Current Periods are set to: ";

"S/T Period: "+WriteVal(p1,3.0);

"I/T Period: "+WriteVal(p2,3.0);

"L/T Period: "+WriteVal(p3,3.0);

" ";

"Select a range on the screen to calculate a period.";

" ";

rangelength = EndValue( BarIndex() ) - BeginValue( BarIndex() );

"Selected Range is "+

WriteVal( rangelength, format = 3.0 )+

" bars";

//------------------------------------------------------

// Use the below plotting for % Width Bands

//------------------------------------------------------

m=2.2;

Plot(cma1*(1+m*dp1),"STUB",colorRed,styleThick);//,Null,Null,Lag1);

Plot(cma1*(1-m*dp1),"LB",colorRed,styleThick);//,Null,Null,Lag1);

Plot(cma2*(1+m*dp2),WriteVal(p2,3.0)+"p"+" UB",colorBlue,styleThick);//Line,Null,Null,Lag1);

Plot(cma2*(1-m*dp2),"LB",colorBlue,styleThick);//Line,Null,Null,Lag1);

Plot(cma3*(1+m*dp3),WriteVal(p3,3.0)+"p"+" UB",colorGreen,styleThick);//,Null,Null,Lag3);

Plot(cma3*(1-m*dp3),"LB",colorGreen,styleThick);//,Null,Null,Lag3);


ub=cma1*(1+m*dp1);

Lb=cma1*(1-m*dp1);

inpercentage1=Sum(IIf(H<ub AND H>lb AND L<ub AND

L>lb,1,0),3*p1)/3/p1*100;

"";

ub=cma2*(1+2*dp2);

Lb=cma2*(1-2*dp2);

inpercentage2=Sum(IIf(H<ub AND H>lb AND L<ub AND

L>lb,1,0),3*p2)/3/p2*100;

ub=cma3*(1+2*dp3);

Lb=cma3*(1-2*dp3);

inpercentage3=Sum(IIf(H<ub AND H>lb AND L<ub AND

L>lb,1,0),3*p3)/3/p3*100;

"";

WriteVal(inpercentage1,3.0)+"% prices within 1st DE over 3 Periods";

WriteVal(inpercentage2,3.0)+"% prices within 2nd DE over 3 Periods";

WriteVal(inpercentage3,3.0)+"% prices within 3rd DE over 3 Periods";

PlotShapes(IIf(Cross(BarIndex(),BarCount-1-

(p1+1)/2),shapeSmallUpTriangle,0), colorRed, 0, cma1*(1-2*dp1));

PlotShapes(IIf(Cross(BarIndex(),BarCount-1-

(p2+1)/2),shapeSmallUpTriangle,0), colorBlue, 0, cma2*(1-2*dp2));

PlotShapes(IIf(Cross(BarIndex(),BarCount-1-

(p3+1)/2),shapeSmallUpTriangle,0), colorGreen, 0, cma3*(1-2*dp3));

//------------------------------------------------------

// Clyde Lee said that Hurst recommended going back one

// full cycle to and copy that centerline shape to the

// shifted CMA to project forward for the envelopes.

//------------------------------------------------------

dy1=LastValue(Ref(cma1,-3*p1/2))-LastValue(Ref(cma1,-p1/2));

RefCMA1=IIf(BarIndex()>=BarCount-p1/2-1,Ref(cma1,-p1),Null)-dy1;

Plot(RefCMA1*(1+m*dp1),"RefUB1",colorYellow);
Plot(RefCMA1*(1-m*dp1),"RefLB1",colorYellow);

 

dy2=LastValue(Ref(cma2,-3*p2/2))-LastValue(Ref(cma2,-p2/2));

Refcma2=IIf(BarIndex()>=BarCount-p2/2-1,Ref(cma2,-p2),Null)-dy2;

Plot(Refcma2*(1+m*dp2),"RefUB1",colorBlack);

Plot(Refcma2*(1-m*dp2),"RefLB1",colorBlack);

dy3=LastValue(Ref(cma3,-3*p3/2))-LastValue(Ref(cma3,-p3/2));

Refcma3=IIf(BarIndex()>=BarCount-p3/2-1,Ref(cma3,-p3),Null)-dy3;

Plot(Refcma3*(1+m*dp3),"RefUB1",colorGold);

Plot(Refcma3*(1-m*dp3),"RefLB1",colorGold);

a1=(C-Ref(C,-1))/(Ref(C,-1))*100;

b = 1041231;

a=DateNum()==b;

i=ValueWhen(a,C);

ii = ((C-i)/i)*100;


Reply via email to