PureBytes Links
Trading Reference Links
|
> This begins the code by saying, "If current year is not equal to the
> year of the previous bar then begin calculating the array." I need to
> change this so that it begins calculations at the year, but also at any
> month or day I input. Something like:
>
> If Year(Date) <> Year(Date[1]) And Month(Date) > Month(Date[Date1])
>
> with Date1 being a new input.
By "but also at any month or day" you sound like you mean "begin
calculations either when the year changes or at any date I input" -- in
which case the AND should be OR.
The way you wrote it, Date1 is being used as a bar offset, not a date,
which will cause problems if it's actually a date. If you want to input
an actual date such as 20020402, you need to say
If Year(Date) <> Year(Date[1]) And Date = Date1 begin
...in which case the test for Year(Date)<>Year(Date[1]) becomes redundant
(assuming you meant AND), so it becomes
If Date = Date1 begin
> I suppose the calculation would end and initialize at the same month and
> day next year like it currently does except at the end of the year.
Yes, I think you meant OR.
If Year(Date) <> Year(Date[1]) or Date = Date1 begin
Because your calculations need to be performed only once when the year
changes and once at some specific date, you want to use date=Date1, you
don't want to test Date>Date1 because then it would initialize every bar
after Date1.
Likewise, if you wanted it to initialize every time the year changes AND
each year every time the month rolls around to the month you input, you
would say something like this:
If year(date)<>year(date[1]) or (month(date)=month(Date1) and
month(date)<>month(date[1])) begin
This will cause the calculation to be triggered twice a year, at the
beginning of January and the beginning of the month contained in Date1.
I hope some of this helped.
-Alex
|