HELP CODING LATEST EHLERS indicator

 

Is there anybody who can write the latest Ehlers indicator from Tradestation to MQL4?

Thanks!

http://www.traders.com/Documentation/FEEDbk_docs/TradersTips/TradersTips.html


Strategy: EhlerBandPassStrat
inputs:
Price( MedianPrice ) ;
variables:
alpha1( 0 ),
alpha1Plus1( 0 ),
Log10( 0 ),
HP( 0 ),
SmoothHP( 0 ),
EhlersDelta( 0.1 ),
EhlersBeta( 0 ),
Cos720Delta( 0 ),
EhlersGamma( 0 ),
alpha( 0 ),
OneMinusAlpha( 0 ),
OnePlusAlpha( 0 ),
N( 0 ),
TwoPi( 6.2831854 ),
MaxAmpl( 0 ),
Num( 0 ),
Denom( 0 ),
DC( 0 ),
DomCyc( 0 ),
Cos720DeltaDom( 0 ),
SineLine( 0 ),
CosineLine( 0 ) ;
arrays:
EhlersI[50]( 0 ),
OldI[50]( 0 ),
OlderI[50]( 0 ),
Q[50]( 0 ),
OldQ[50]( 0 ),
OlderQ[50]( 0 ),
Real[50]( 0 ),
OldReal[50]( 0 ),
OlderReal[50]( 0 ),
Imag[50]( 0 ),
OldImag[50]( 0 ),
OlderImag[50]( 0 ),
Ampl[50]( 0 ),
OldAmpl[50]( 0 ),
DB[50]( 0 ) ;

if CurrentBar = 1 then
begin
{ 360 / 40 = 9 }
alpha1 = ( 1 - Sine( 9 ) ) / Cosine( 9 ) ;
alpha1Plus1 = alpha1 + 1 ;
Log10 = Log( 10 ) ;
end ;
HP = 0.5 * alpha1Plus1 * ( 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 = 1 then
SmoothHP = 0
else if CurrentBar < 7 then
SmoothHP = Price - Price[1] ;
EhlersDelta = -0.015 * CurrentBar + 0.5 ;
EhlersDelta = MaxList( 0.15, EhlersDelta ) ;
if CurrentBar > 6 then
begin
for N = 8 to 50
begin
EhlersBeta = Cosine( 360 / N ) ;
Cos720Delta = Cosine( 720 * EhlersDelta / N ) ;
if Cos720Delta <> 0 then
EhlersGamma = 1 / Cos720Delta ;
alpha = EhlersGamma -
SquareRoot( Square( EhlersGamma ) - 1 ) ;
OneMinusAlpha = 1 - alpha ;
OnePlusAlpha = 1 + alpha ;
Q[N] = ( N / TwoPi ) * ( SmoothHP -
SmoothHP[1] ) ;
EhlersI[N] = SmoothHP ;
Real[N] = 0.5 * OneMinusAlpha * ( EhlersI[N] -
OlderI[N] ) + EhlersBeta * OnePlusAlpha *
OldReal[N] - alpha * OlderReal[N] ;
Imag[N] = 0.5 * OneMinusAlpha * ( Q[N] -
OlderQ[N] ) + EhlersBeta * OnePlusAlpha *
OldImag[N] - alpha * OlderImag[N] ;
Ampl[N] = ( Square( Real[N] ) +
Square( Imag[N] ) ) ;
end ;
end ;
for N = 8 to 50
begin
OlderI[N] = OldI[N] ;
OldI[N] = EhlersI[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] ;
end ;
MaxAmpl = Ampl[10] ;
for N = 8 to 50
begin
if Ampl[N] > MaxAmpl then
MaxAmpl = Ampl[N] ;
end ;
for N = 8 to 50
begin
if MaxAmpl <> 0 and ( Ampl[N] / MaxAmpl ) > 0 then
DB[N] = -10 * Log( 0.01 / ( 1 - .99 * Ampl[N] /
MaxAmpl ) ) / Log10 ;
if DB[N] > 20 then
DB[N] = 20 ;
end ;
Num = 0 ;
Denom = 0 ;
for N = 10 to 50
begin
if DB[N] <= 3 then
begin
Num = Num + N * ( 20 - DB[N] ) ;
Denom = Denom + ( 20 - DB[N] ) ;
end ;
if Denom <> 0 then
DC = Num / Denom ;
end ;
DomCyc = Median( DC, 10 ) ;
if DomCyc < 8 then
DomCyc = 20 ;
EhlersBeta = Cosine( 360 / DomCyc ) ;
Cos720DeltaDom = Cosine( 720 * EhlersDelta / DomCyc ) ;
if Cos720DeltaDom <> 0 then
EhlersGamma = 1 / Cos720DeltaDom ;
alpha = EhlersGamma - SquareRoot( Square( EhlersGamma )
- 1 ) ;
SineLine = 0.5 * ( 1 - alpha ) * ( SmoothHP -
IndicatorIndicator SmoothHP[1] ) + EhlersBeta * ( 1 + alpha ) *
SineLine[1] - alpha * SineLine[2] ;
CosineLine = ( DomCyc / TwoPi ) * ( SineLine -
SineLine[1] ) ;
if CurrentBar > 10 then
begin
if CosineLine crosses over SineLine then
Buy next bar market
else if CosineLine crosses under SineLine then
Sell short next bar at market ;
end ;

 

Anybody can help?

I have tried to code this but nothing is dsplayed.

To see a good working code for this will alsp help me to undrstand my mistakes and learn the language better.

Thanks

 
Any help? Thanks
 

any suggestions?