Automatic Fibonacci Levels
Inputs: FibColor( Yellow ), FibStyle( Tool_Dotted );
Variables: Count( 0 ), Top( 0 ), TopBar( 0 ), Bottom( 0 ), BottomBar( 0 ), RefBar( 0 );
Arrays: FibLevel[ 2, 33 ]( 0 ),
LineIDs[ 33 ]( 0 ),
TextIDs[ 33 ]( 0 );
If Date = CurrentDate Then
Begin
Bottom = ( HighD( 1 ) + LowD( 1 ) + CloseD( 1 ) ) / 3;
Top = 2 * Bottom - LowD( 1 );
TopBar = 1;
BottomBar = 1;
RefBar = 1;
End;
If Top <> Top[1] OR Bottom <> Bottom[1] Then
Begin
Condition1 = FibLevels( Top, Bottom, FibLevel );
If LineIDs[1] <> 0 Then
Begin
For Count = 0 to 33
Begin
Value1 = TL_Delete( LineIDs[ Count ] );
Value1 = Text_Delete( TextIDs[ Count ] );
LineIDs[ Count ] = 0;
TextIDs[ Count ] = 0;
End;
End
Else
Begin
For Count = 0 to 33
Begin
LineIDs[ Count ] = TL_New( Date[ RefBar ], Time[ RefBar ], FibLevel[ 2, Count ], Date, Time, FibLevel[ 2, Count ] );
TL_SetExtLeft( LineIDs[ Count ], false );
TL_SetExtRight( LineIDs[ Count ], true );
? ?TL_SetColor( LineIDs[ Count ], FibColor );
TL_SetStyle( LineIDs[ Count ], FibStyle );
TextIDs[ Count ] = Text_New( Date, Time, FibLevel[ 2, Count ], NumToStr( FibLevel[ 1, Count ] * 100, 1 ) + "%" );
Text_SetStyle( TextIDs[ Count ], 1, 0 );
Text_SetColor( TextIDs[ Count ], FibColor );
End;
End;
Plot1[TopBar]( Top, "Top" );
Plot2[BottomBar]( Bottom, "Bottom" );
End
Else
Begin
NoPlot( 1 );
NoPlot( 2 );
End;
(Edited by JPR at 9:01 pm op 30,okt. 2003)