Hi!
I want to ask if you can help me sort out the following problem. I am trying to verify an indicator code in the easy language editor but the editor fails to uderstand some of the words in it (Indicator: Siligardos Autotrend,TrendlineUp,TrendlineDown). I took the code from the following webpage and it plots automatic trendlines- http://www.traders.com/Documentation/FEEDbk_docs/Archive/112006/TradersTips/TradersTips.html
Here is the code:
Please let me know if it is possibe to correct this problem.
Thanks!!!
Dima
I want to ask if you can help me sort out the following problem. I am trying to verify an indicator code in the easy language editor but the editor fails to uderstand some of the words in it (Indicator: Siligardos Autotrend,TrendlineUp,TrendlineDown). I took the code from the following webpage and it plots automatic trendlines- http://www.traders.com/Documentation/FEEDbk_docs/Archive/112006/TradersTips/TradersTips.html
Here is the code:
Code:
Indicator: Siligardos Autotrend
inputs:
Threshold( 30 ),
Lookback( 300 ) ;
variables:
TrendLineBuilt( false ),
PivotsFound( 0 ),
f( 0 ),
b( 0 ),
x( 0 ),
y( 0 ),
F1( 0 ),
F2( 0 ),
F3( 0 ),
PF1( 0 ),
PF2( 0 ),
PF3( 0 ) ;
arrays:
PivotArray[500]( 0 ),
PivotType[4]( 0 ),
PivotPosition[4]( 0 ),
SI[500]( 0 ) ;
if LastBarOnChart then
begin
for x = 1 to Lookback
begin
PivotArray[x] = 0 ;
end ;
F1 = 1 ;
F2 = F1 ;
PF1 = Close[F1] ;
PF2 = Close[F2] ;
{find the first move greater than threshold percent}
while ( 100 *AbsValue( PF1 - PF2 ) / MinList( PF1, PF2 )
< Threshold and ( F2 < Lookback ) )
begin
F2 = F2 + 1 ;
PF2 = Close[F2] ;
end ;
F3 = F2 ;
PF3 = Close[F3] ;
while F1 < Lookback
begin
while ( ( (100 * AbsValue( PF2 - PF3 )
/ MinList( PF2, PF3 ) < Threshold )
or ( ( ( PF1 < PF2 ) and ( PF2 <= PF3 ) )
or ( ( PF1>PF2) and ( PF2 >= PF3 ) ) ) )
and ( F3 < Lookback ) )
begin
if ( ( ( PF1 < PF2 ) and ( PF2 <= PF3 ) )
or ( ( PF1 > PF2 ) and ( PF2 >= PF3 ) ) )
then
begin
F2 = F3 ;
PF2 = Close[F2] ;
end ;
F3 = F3 + 1 ;
PF3 = Close[F3] ;
end ;
if ( ( F3 = Lookback ) ) then
begin
F1 = F2 ;
F2 = F3 ;
PF1 = Close[F1] ;
PF2 = Close[F2] ;
end ;
if ( F2 > F1 ) then
begin
PivotArray[F2] = 1 ;
F1 = F2 ;
F2 = F3 ;
PF1 = Close[F1] ;
PF2 = Close[F2] ;
end ;
end ;
PivotArray[1] = 0 ;
PivotArray[Lookback] = 0 ;
end ;
if LastBarOnChart then
begin
x = 1 ;
y = 1 ;
while ( y < Lookback )
begin
y = y + 1 ;
if ( ( PivotArray[ y ] <> 0 )
or ( y = Lookback ) )
then
begin
b = ( Close[y] - Close[x] ) / ( y - x ) ;
for f = x to y
begin
SI[f] = ( b * ( f - x ) + Close[x] ) ;
end ;
x = y ;
end ;
end ;
F = 2 ;
{locate pivots}
PivotsFound = 0 ;
while ( ( F < Lookback - 2 ) and ( PivotsFound < 4 ) )
begin
if ( ( SI[f] <= SI[ f + 1 ] )
and ( SI[ f - 1 ] >= SI[f] ) )
then
begin
PivotsFound = PivotsFound + 1 ;
PivotType[ 5 - PivotsFound ] = + 1 ;
PivotPosition[ 5 - PivotsFound ] = F ;
end ;
if ( ( SI[f] >= SI[ f + 1 ] )
and (SI[ f - 1 ] <= SI[f] ) )
then
begin
PivotsFound = PivotsFound + 1 ;
PivotType[ 5 - PivotsFound ] = - 1 ;
PivotPosition[ 5 - PivotsFound ] = f ;
end ;
F = F + 1 ;
end ;
if ( PivotsFound = 4 ) then
begin
if ( PivotType[2] = 1 )
and ( PivotType[4] = 1 )
and ( Close[ PivotPosition[2] ]
< Close[ PivotPosition[4] ] )
and ( MaxList( Close[ PivotPosition[2] ],
Close[ PivotPosition[4] ] )
< MaxList( High[ PivotPosition[4] ],Close[0] ) )
then
begin
Value1 = TrendlineUp( Lookback,
PivotPosition[2],PivotPosition[4] ) ;
TrendlineBuilt = true ;
end
else if ( PivotType[2] = -1 )
and ( PivotType[4] = -1 )
and ( Close[ PivotPosition[2] ]
> Close[ PivotPosition[4] ] )
and ( MinList( Close[ PivotPosition[2] ],
Close[ PivotPosition[4] ] ) > MinList
( Close[ PivotPosition[4] ], Close[0] ) )
then
begin
Value1 = TrendlineDown( Lookback,
PivotPosition[2], PivotPosition[4] );
TrendlineBuilt = true ;
end
else
Print( " Lookback trendline can be drawn,",
"Threshold = ", Threshold ) ;
end ;
if ( PivotsFound >= 3 ) and TrendLineBuilt = false then
begin
if ( PivotType[1] = 1 )
and ( PivotType[3] = 1 )
and ( Close[ PivotPosition[1] ] <
Close[ PivotPosition[3] ] )
and ( MaxList( Close[ PivotPosition[1] ],
Close[ PivotPosition[3] ] ) < MaxList(
Close[ PivotPosition[3] ], Close[0] ) )
then
Value1 = TrendlineUp( Lookback,
PivotPosition[1], PivotPosition[3] )
else if ( PivotType[1] = -1 )
and ( PivotType[3] = -1 )
and ( Close[PivotPosition[1] ] >
Close[ PivotPosition[3] ] )
and ( MinList( Close[ PivotPosition[1] ],
Close[ PivotPosition[3] ] ) > MinList(
Close[ PivotPosition[3] ], Close[0] ) )
then
Value1 = TrendlineDown( Lookback,
PivotPosition[1], PivotPosition[3] )
else
Print( "No trendline can be drawn,",
"Threshold = ", Threshold ) ;
end
else
Print( "No trendline can be drawn,",
"Threshold = ", Threshold ) ;
if ( PivotsFound < 3 ) then
Print( "No Point Milestones Can Be Found,",
"Threshold = ", Threshold ) ;
end ;
Please let me know if it is possibe to correct this problem.
Thanks!!!
Dima