Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 04-20-2009, 07:31 PM   #17

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Center of Gravity Bands

Quote:
Originally Posted by mtorri »
Hi all.

I'm also searching for an easylanguage implementation of the center of gravity bands, also known as Hurst bands.
I have the following code which works well in proprealtime.
I tried to translate it in tradestation, it looks easy, but the results are wrong.
My problem is the DPO function used in the prorealtime code.
I substituted it using the detrend function in tradestation but it's not the same.
So I'm not able to go on.
Anyone can help?
...
do you have the code for DPO ?
Tams is offline  
Reply With Quote
Old 05-02-2009, 05:16 PM   #18

Join Date: Mar 2008
Location: Cesena
Posts: 3
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Re: Center of Gravity Bands

unfortunately not, i searched for it without sucess.
The prorealtime platform, describing how DPO works, says it does exactly what the tradestation detrend function do.
But if you plot the DPO you can see two big differences compared to the detrend
1) it is shifted on the left by LEN/2 bars (where LEN is the input length)
2) it is normalized so that it moves form -100 to 100

here is an example of the DPO and hurst bands on prorealtime.
Attached Thumbnails
Center of Gravity Bands-hurst_dpo.jpg  
mtorri is offline  
Reply With Quote
Old 05-02-2009, 05:55 PM   #19

Join Date: Mar 2008
Location: Cesena
Posts: 3
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Re: Center of Gravity Bands

Quote:
Originally Posted by moneymarkets »
Thanks for your input, would you mind posting what you have for easylanguage so far, to see if we can help?
thanks
This is the tradestatione code

A function:
---------
Inputs: p3(numericsimple), XX(numericsimple), HurstM(numericRef),HurstH (numericRef),HurstL(numer icref);

Variables: k(0), de48(0), n(0), p(0), d100(0), moy100(0), co(0), hh(0), x(0), w(0), aa(0),b(0),e(0), z(0),
alpha(0), bbeta(0), flag(0), p33(0), ii(0),cc(0), dd(0);

k=p3;
de48=Detrend( CLOSE, k*2);

if de48=de48[1] and de48[1]=de48[2] and de48[2]<>de48[3] then flag=1;
n=(k*2)-4;
p=(n/2)-1;
d100=Detrend(close,n);
moy100=close-d100;

co=(moy100-moy100[1]+(close[p])/n)*n;
//co=(moy100-moy100[1]+div(close[p],n))*n;

if flag[1]=1 and flag[2]=0 then hh=co[1];
if flag[1]=1 then co=hh;
n=mod(p3,2);
p=(p3-n)/2;
p33=(2*p)+1;

//once x=0
w=absvalue((p-x)/p);
//w=absvalue( div(p-x,p) );

w=w*w*w;
w=(1-w);
w=w*w*w;
x=x+1;
if barnumber=p33 then
begin
aa=0;
b=0;
e=0;
for ii=1 to p33 begin
z=barnumber-ii+1;
aa=aa+w[z];
b=b+w[z]*(ii);
e=e+(ii)*(ii)*w[z];
end;
end;
if barnumber>p33 then
begin
cc=0;
dd=0;
for ii=1 to p33 begin
z=barnumber-ii+1;
cc=cc+co[p33+p-ii]*w[z];
dd=dd+co[p33+p-ii]*w[z]*(ii);
end;
end;
//alpha=(aa*dd-b*cc)/(aa*e-b*b);
alpha=div((aa*dd-b*cc),(aa*e-b*b));

//bbeta=(cc*e-b*dd)/(aa*e-b*b);
bbeta=div((cc*e-b*dd),(aa*e-b*b));

HurstM=alpha*(p+1)+bbeta;
if barnumber<p33*2 then
begin
HurstM=0;
HurstH=0;
HurstL=0;
end;

HurstH=HurstM+xx;
HurstL=HurstM-xx;

AA_BandeHurst=0;
--------------------

and its indicator:
-------------
inputs: p3(83), XX(0.75);

Variables: HurstM(0), HurstH(0), HurstL(0);

Value1= AA_BandeHurst(p3, XX, HurstM, HurstH, HurstL);

Plot1( HurstM, "HurstM" ) ;

Plot2( HurstH, "HurstH" ) ;

Plot3( HurstL, "HurstL" ) ;
-----------

I also attach 2 images on the same bund future contract daily where I show the bad results on tradestation and the nice hurst bands on prorealtime.

And here is the prorealtme code creating this bands
I shifted the upper and the lower band only by 0.75 so the bands are not "perfect".
But the most important thing is the central line.
-----

k=p3 //(input value)
de48=DPO[k*2](close)
if de48=de48[1] and de48[1]=de48[2] and de48[2]<>de48[3] then
flag=1
endif
n=(k*2)-4
p=(n/2)-1
d100=DPO[n](close)
moy100=close-d100
co=(moy100-moy100[1]+(close[p])/n)*n
if flag[1]=1 and flag[2]=0 then
hh=co[1]
endif
if flag[1]=1 then
co=hh
endif
n=p3 mod 2
p=(p3-n)/2
p3=(2*p)+1
once x=0
w=abs((p-x)/p)
w=w*w*w
w=(1-w)
w=w*w*w
x=x+1
if barindex=p3 then
a=0
b=0
e=0
for i=1 to p3
z=barindex-i+1
a=a+w[z]
b=b+w[z]*(i)
e=e+(i)*(i)*w[z]
next
endif
if barindex>p3 then
c=0
d=0
for i=1 to p3
z=barindex-i+1
c=c+co[p3+p-i]*w[z]
d=d+co[p3+p-i]*w[z]*(i)
next
endif
alpha=(a*d-b*c)/(a*e-b*b)
beta=(c*e-b*d)/(a*e-b*b)
lowess=alpha*(p+1)+beta
if barindex<p3*2 then
lowess=undefined
endif
lowess1=lowess+xx
lowess2=lowess-xx
Segno=SGN(lowess-lowess[1])
return lowess as "H media", lowess1 coloured by (Segno) as "UpperBand", lowess2 coloured by (Segno) as "LowerBand"
-----------
Attached Thumbnails
Center of Gravity Bands-hurst_prorealtime.jpg   Center of Gravity Bands-hurst_tradestation.jpg  
mtorri is offline  
Reply With Quote
Old 05-02-2009, 06:59 PM   #20

Join Date: Apr 2007
Location: Andalusia
Posts: 23
Ignore this user

Thanks: 3
Thanked 1 Time in 1 Post

Re: Center of Gravity Bands

Thanks for your information and post.
I get an error when trying to verify the below statement--needs more inputs???
alpha=div((aa*dd-b*cc),(aa*e-b*b));
moneymarkets is offline  
Reply With Quote
Old 05-27-2011, 01:02 AM   #21

Trendup_'s Avatar

Join Date: Sep 2008
Location: DownUnder
Posts: 136
Ignore this user

Thanks: 73
Thanked 42 Times in 33 Posts

Re: Center of Gravity Bands

Did you find the COG easy language version?
Can anyone share it?
Trendup_ is offline  
Reply With Quote

Reply

Tags
center of gravity, john ehlers

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sigma Bands for CQG Soultrader Trading Indicators 12 01-05-2010 06:27 PM
Question regarding Bollinger Bands Robert Technical Analysis 22 08-08-2009 10:37 PM
CQG VWAP SD Bands Creation??? Garylim Market Profile 11 03-22-2009 04:32 PM
Volatility Bands scalper4 Coding Forum 9 03-08-2009 06:39 PM
Problem with Better Bollinger Bands HBBHVN Coding Forum 1 02-24-2009 06:12 AM

All times are GMT -4. The time now is 12:43 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.