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

RE: TS2k LastBarOnChart??



PureBytes Links

Trading Reference Links

For whatever reason it's processing the last bar twice when using
LastBarOnChart (or LastCalcDate).  When you run the code posted by ztrader,
EL seems to return the correct answer (Highest of last 11 bars).  However,
when you include the loop (for or while), BarNUmber is 10 less on the first
cycle than when you don't include for/next loop.  On the second cycle (seem
data below) TS seems to correct itself.  This probably has to do with how TS
processes internally but the 2nd time it iterates through the loop it prints
out the correct numbers (goes barnumber = 4518, 4529, 4519).  For example, I
had 4529 bars of SP daily data.  When for/while loops were included, the
first pass through prints the wrong barnumber (4529) but the Text_New plot
and the plot1 function print (4519) for the last barnumber.  All in all, TS
may process things twice on the last bar internally which is not expected
but it doesn't seem to yield innacurate results.  The work around would be
to use the Highest(H, 11) function to get the highest high of the last 0 to
10 bars rather than use a loop and the eliminate the loop on the last bar.
Take a look at HiHi ad HiHi2. They produce the same result.

      0.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      1.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      2.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      3.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      4.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      5.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      6.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      7.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      8.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      9.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
     10.00   4529.00   1011210.00   1011210.00       1630.00       1630.00
      0.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      1.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      2.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      3.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      4.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      5.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      6.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      7.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      8.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
      9.00   4519.00   1011210.00   1011210.00       1630.00       1630.00
     10.00   4519.00   1011210.00   1011210.00       1630.00       1630.00

{TS study: TestLastBarChart2

}


Inputs: HLbarBk (20)
                ;

Variables: init(true), LBinit(true), dd(0),
        HiHi(0), LastLBBar(0), EndDate(0), EndTime(0), x(0) ;

if init then begin
        EndDate= LastCalcDate ;
		EndTime= LastCalcTime;
        init = false ;
end;

{Value1 = Text_New(d, t, h, NumToStr(BarNumber,0));}

{if date=EndDate AND Time = EndTime AND LBinit then begin }

Var: HiHi2(0);


If LastBarOnChart Then Begin
        {LBinit = false;}
		{
		x = 0;
        while x <= 10 Begin
			if High[x] > HiHi then HiHi = High[x] ;
			Print( x,  barnumber, "   ", date, "   ", LastCalcDate, "    ", time, "
", LastCalcTime ) ;
			x = x + 1;
		end;
		}

		for x = 0 to 10 begin
                if High[x] > HiHi then HiHi = High[x] ;
                	Print(LastCalcJDate);
					Print( x,  barnumber, "   ", date, "   ", LastCalcDate, "    ", time, "
", LastCalcTime ) ;
        end;

		HiHi2 = Highest(H, 11);

end;


Print(HiHi);
Print(HiHi2);

-----Original Message-----
From: ztrader [mailto:ztrader@xxxxxxxxx]
Sent: Tuesday, December 11, 2001 11:02 PM
To: omega-list
Subject: TS2k LastBarOnChart??


When I run the code below in TS2k with daily bars, it seems to run
twice, once with the true last bar, and once again at last bar minus
the max value of x in the loop(check the barnumbers in the print).
Could we possibly have a bug in TS2k EL? Such a thought might even get
PO to respond. :-)

Any ideas for a work-around?

Thanks,

ztrader

------------------------------

{TS study: TestLastBarChart2

}


Inputs: HLbarBk (20)
                ;

Variables: init(true), LBinit(true), dd(0),
        HiHi(0), LastLBBar(0), EndDate(0), EndTime(0), x(0) ;

if init then begin
        EndDate= LastCalcDate ; EndTime= LastCalcTime;
        init = false ;
end;

if date=EndDate AND Time = EndTime AND LBinit then begin
         LBinit = false;
        for x = 0 to 10 begin
                if High[x] > HiHi then begin
                        HiHi = High[x] ;
                end ;
print( x,  barnumber, date, LastCalcDate, time, LastCalcTime ) ;

        end;
end;

If CurrentBar < -999999 Then Begin
        Plot1(22, "dummy");
End;