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

Re: date>date[1]



PureBytes Links

Trading Reference Links

Ian:

>sess1firstbartime  returns the time of the *end* of the first bar which 
>effectively would leave the first bar out of any calculations, is that 
>right?

No, that's wrong.

The values Open, High, Low, Close always refer to the bar that has
just completed.  Therefore when time=Sess1FirstBarTime, then the
values Open, High, Low, and Close pertain to that first bar.  It
will not be left out.

This makes sense when you think about it.  One can't know future prices,
so the *only* possible way to interpret O,H,L,C are as prices of the
most recently-completed bar.

>If so, are there any other alternatives? What do you clever 
>programmers use?

There are other times, like Sess1StartTime, but you don't want to test
if time=Sess1StartTime because it will never be true unless a bar closes
at that time.  Instead you might try
if time crosses over Sess1StartTime then...

Which is equivalent to
if time=Sess1FirstBarTime then....

But the "crosses over" test will still work in those rare cases when
you might be missing the first bar of the day in your data.

-Alex