[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Plot bars into future based on previous swing high/low?



PureBytes Links

Trading Reference Links

I am trying to take a previous swing high/low and project so many bars into the future. I am having trouble with some vertical plots. Here is the code, if anyone can help.
Thanks!
I want to take a swing high/low from 35 bars ago, and project into the future 45 & 90 bars from that swing point. The cyan and magenta vertical lines do not plot correctly.

{************************************** ***
Time Forcast + Vertical Lines
******************************************}


Inputs: Length(35),
Forward1(45),
Forward2(90),
OnlyLast(true);

Vars: TL_Begin(0), TL_End(0) ;
Vars: Direct(0);

Direct = Swing_Lee(Length);
if HighestBar( High, Direct ) = 0 and OnlyLast Then begin
Plot1[ -Forward1 ]( High, "High" ) ;
TL_Begin = TL_New(Date, Time, High, Date, Time, Low);
TL_SetColor( TL_Begin, Red );
TL_SetStyle( TL_Begin, Tool_Dotted );
TL_SetExtLeft( TL_Begin, True);
TL_SetExtRight( TL_Begin, True);
End;
if HighestBar( High, Direct ) = 0 and OnlyLast Then begin
Plot2[ -Forward2 ]( High, "High" );
TL_Begin = TL_New(Date, Time, High, Date, Time, Low);
TL_SetColor( TL_Begin, Magenta );
TL_SetStyle( TL_Begin, Tool_Dotted );
TL_SetExtLeft( TL_Begin, True);
TL_SetExtRight( TL_Begin, True);
End;

If LowestBar( Low, Direct ) = 0 and OnlyLast then Begin
Plot3[ -Forward1 ]( Low, "Low" ) ;
TL_End = TL_New(Date, Time, High, Date, Time, Low);
TL_SetColor( TL_End, Green );
TL_SetStyle( TL_End, Tool_Dotted );
TL_SetExtLeft( TL_End, True);
TL_SetExtRight( TL_End, True);
End;
If LowestBar( Low, Direct ) = 0 and OnlyLast then Begin
Plot4[ -Forward2 ]( Low, "Low" );
TL_End = TL_New(Date, Time, High, Date, Time, Low);
TL_SetColor( TL_End, Cyan );
TL_SetStyle( TL_End, Tool_Dotted );
TL_SetExtLeft( TL_End, True);
TL_SetExtRight( TL_End, True);
End;