log in     sign up for free
 
If you really think the stock is going to make a big move - and that should be the only reason you are buying the stock to begin with - then there is no reason to haggle over an eighth of a point. Just buy the stock.
David Ryan
 
 
Home
systems (284)
 
Special offer: buy AmiBroker and EOD+Real-Time Data
 
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

Hilbert Channel Indicator

Formula for: TradeStation

indicator


 

 

Views:  2425

Added: June 02, 2008
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 

email this link

 
 
Tags: TradeStation, indicator
 
Your Ad Here


Code:

Typ : Function, Name : HilbertPeriod
{ ----------------------------------------------------------
HilbertPeriod (Function) by John Ehlers (7/22/00)
This is the Hilbert Cycle Period Function used by the Hilbert
Channel Breakout System. It must be named "HilbertPeriod".
---------------------------------------------------------- }

Inputs: Price(numeric);

Vars: Smoother(0), Detrender(0), I1(0), Q1(0), jI(0), jQ(0), I2(0),Q2(0), X1(0),
X2(0), Y1(0), Y2(0), Re(0), Im(0), Period(0);

If CurrentBar >5 then begin
Smoother = (4*Price + 3*Price[1] + 2*Price[2] + Price[3])/10;
Detrender = (.25*Smoother + .75*Smoother[2] - .75*Smoother[4] -
.25*Smoother[6])*(.046*Period[1] + .332);

{Compute InPhase and Quadrature components}
Q1 = (.25*Detrender + .75*Detrender[2] - .75*Detrender[4] -
.25*Detrender[6])*(.046*Period[1] + .332);
I1 = Detrender[3];

{advance the phase of I1 and Q1 by 90 degrees}
jI = .25*I1 + .75*I1[2] - .75*I1[4] - .25*I1[6];
jQ = .25*Q1 + .75*Q1[2] - .75*Q1[4] - .25*Q1[6];
{Phasor addition to equalize amplitude due to quadrature calculations
(and 3 bar averaging)}
I2 = I1 - jQ;
Q2 = Q1 + jI;

{Smooth the I and Q components before applying the discriminator}
I2 = .15*I2 + .85*I2[1];
Q2 = .15*Q2 + .85*Q2[1];

{Homodyne Discriminator}
{Complex Conjugate Multiply}
X1 = I2*I2[1];
X2 = I2*Q2[1];
Y1 = Q2*Q2[1];
Y2 = Q2*I2[1];
Re = X1 + Y1;
Im = X2 - Y2;

{Smooth to remove undesired cross products}
Re = .2*Re + .8*Re[1];
Im = .2*Im + .8*Im[1];

{Compute Cycle Period}
If Im <> 0 and Re <> 0 then Period = 360/ArcTangent(Im/Re);
If Period > 1.5*Period[1] then Period = 1.5*Period[1];
If Period < .67*Period[1] then Period = .67*Period[1];
If Period < 6 then Period = 6;
If Period > 50 then Period = 50;
Period = .2*Period + .8*Period[1];

{END CORE CODE}

HilbertPeriod = Period;

end;





Typ : Indicator, Name : Hilbert Channel Indicator
{********************************************************************************
Hilbert_Channel (Indicator)

This is the indicator for the Hilbert Channel Breakout System.

After the Hilbert Channel Breakout Signal is optimized, set the inputs for this
indicator to match the corresponding inputs for the signal.
Also set the "Max number of bars the study will reference" on the indicator's
Properties tab to the corresponding value on the Properties tab for the signal.

Plot1 and plot2 should be lines; plot3 and plot 4 should be medium-thin points.
******************************************************************************** }

inputs: Price((H + L)/2),
EntryVal(0),
EntryK(0),
ExitVal(0),
ExitK(0);

vars: Period(0),
count(0),
EntryLookBack(0),
ExitLookBack(0),
EntryChannel(0),
ExitChannel(0);

Period = HilbertPeriod(Price);

If EntryVal <> 0 then EntryLookBack = EntryVal else EntryLookBack = EntryK*Period;
if EntryLookBack < 1 then EntryLookBack = 1;

If ExitVal <> 0 then ExitLookBack = ExitVal else ExitLookBack = ExitK*Period;
if ExitLookBack < 1 then ExitLookBack = 1;

EntryChannel = 0;
for count = 1 to EntryLookBack begin
if EntryChannel < High[count] then EntryChannel = High[count];
end;

ExitChannel = 100000;
for count = 1 to ExitLookBack begin
if ExitChannel > Low[count] then ExitChannel = Low[count];
end;

plot1(EntryChannel, "EntryChannel");
plot2(ExitChannel, "ExitChannel");

If High > EntryChannel then plot3(EntryChannel, "Enter");
If Low < ExitChannel then plot4(ExitChannel, "Exit");



 






Author: Roger Darley
Source: http://www.traders.com

 

View similar (indicator for TradeStation):

Close From One Day To The Next
Time and Money Indicators
Double Smoothed Exponential Moving Average
RAVI II
HI LO Activator
LMS Predictor
Tether Line
VIDYA
RAVI
Swing Wave Indicator
...
 
 
all formulas for TradeStation
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
 
Privacy note | (c) copyrights systems4trading.com 2006-2012