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

Re : How to detect the very last bar in a series???



PureBytes Links

Trading Reference Links

Dans un courrier daté du 03/06/98 01:53:55  , vous avez écrit :

<< 
 I need to detect the very last bar in a series.  Pierre Orphelin's
 finddate(-1) DLL function seems to give undefined results on the last
 bar, so the best I could do was come up with the "BarIsLast" function
 below which incorporates finddate.  It seems to do the job, but I'm not
 sure how reliably it will work in the long term.  [Note that I need to
 be able to do this from indicators & systems, thus I can't use "date of
 next bar".]  Hopefully one of you might know of a better way...
 
 Thanks & rgds,
 Bernie
 ----------
 Variables:
    BarDateNext(0),
    BarYearNext(0),
    BarYear(0);
 
 definedllfunc:"c:\omega\prog\ts_find.dll",dword,"findDate",lpword,int;
 
 BarDateNext = findDate(&date,-1);
 BarYearNext = Year(BarDateNext);
 BarYear	    = Year(Date);
 
 BarIsLast = BarYearNext<>BarYear and BarYearNext<>BarYear+1;
 >>

The above DLL function reads date, time, open ,close and so on bars in
advance, but only with historical data.
When the last bar occurs, the result do not exist, because there is no bar in
advance to read in the database.

If you want to check that the current bar is the last bar on the chart, you
must use the LastBarOnChart user function:

if LastBarOnChart=true  then do something.

But it does not give you the date of tomorrow (that must be stored somewhere)
and in any case the close of tomorrow.

In a word, this DLL is used to do some testing on historical data to access
future data from a bar located in the past, the limitation being the true last
bar where nothing cannot be predicted (date excepted, but with a perpetual
calendar)

Sincerely,

Pierre Orphelin