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

Re: On the first bar, how to access the last bar?


  • To: Traktor Topaz <traktor@xxxxxxxxxxx>
  • Subject: Re: On the first bar, how to access the last bar?
  • From: Mike Eggleston <mikee@xxxxxxxxxxxxxx>
  • Date: Tue, 17 Sep 2002 07:43:13 -0700
  • In-reply-to: <200209170149.SAA32329@xxxxxxxxxxxxxx>

PureBytes Links

Trading Reference Links

On Tue, 17 Sep 2002, Traktor Topaz wrote:

> 
>    This is probably simple, but it's eluded me so far:
> 
>    I wish to go through the bars of a given contract, performing some
> statistical calculations, looking to see how often something happens. But
> before I run through the bars I need to know one simple thing about the
> last and next-to-last bars.
> 
>    As a (simplified) example, let's say that today (the last bar on the
> chart) the open is so-much higher/lower than yesterday's open, and now I
> want to run through all the bars and count up how often that is the case.
> So I'd like code like this:
> 
>    If currentbar > 1 then begin
> 
> 	OpenPosition = Open[lastdayonchart] - Open[nexttolastdayonchart];
> 
> 	if open[today] blah-blah open[yesterday] then add-some-stuff-up.
> 
> 	if lastbaronchart then plot1( results, 'results' );
> 
>    end;
> 
>    The part that's eluded me so far is how, on the first (or second) bar of
> the chart to find out how many bars  exist in this chart so as to access
> the last-bar and next-to-last-bar on the chart.

I don't think it is possible to look into the future. However, you can
write an indicator that waits until it is on the last bar (lastbaronchart = true)
and when it is on the last bar it then does your statistical calculation.

Mike