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

Re[2]: Why does this TrendLine function fails at times?



PureBytes Links

Trading Reference Links

TaoOfDow,

thanks.  Here's what I have now.  It seems to work.
Apparently, the original code was building two trendlines on
the same bar and the code was loosing track of one of them.
(Even when when update on everytick was reset).  I
don't understand this.  But adding logic to only draw one line
per bar pervents the "bug".

input: Level(numericsimple),plotcolor(numericsimple);;
var: LastLevel(-1),atbar(-1);
var: TL_Level_ID(-1);
if Level<>LastLevel then begin
        if LastLevel <> -1 or TL_Level_ID <> -1 then begin
                TL_SetExtRight( TL_Level_ID, false ) ;
                TL_SetEnd( TL_Level_ID, Date, Time, LastLevel ) ;
                LastLevel=-1;
                end;
        if atbar<> currentbar then begin 
                TL_Level_ID = TL_New( Date, time[1], Level, Date, Time, Level ) ;
                TL_SetColor( TL_Level_ID, plotcolor ) ;
                TL_SetExtLeft( TL_Level_ID, false ) ;
                TL_SetExtRight( TL_Level_ID, true ) ;
                LastLevel = Level;
                atbar = currentbar;
                end;
        end;
ebTL= TL_Level_ID;


Regards,
Ernie
ebonugli@xxxxxxxx