Accumulation function problem

I’m using the following script to count new highs over a given period.

H1=HIGH()>HIGHESTHIGH(BACKTYPE, BARS=22);

ACC( H1, RANGE=Look Back Period, BACKTYPE, BARS=22) //bar type == close

When I manually check the counts they are not correct as I want the new highs not new closes.
If I use this script I just get rubbish answers.

H1=HIGH()>HIGHESTHIGH(BACKTYPE, BARS=22);
ACC( H1, RANGE=Look Back Period, BACKTYPE, BARS=22, BARTYPE=High)

Can someone show me my error.
Thanks Peter

Hi Peter,

Cange your script to this:
[scode lang=“{language}”]
H1=HIGH()>HIGHESTHIGH(BACKTYPE, BARS=22);
ACC( H1, RANGE=Look Back Period, BARS=22)
[/scode]

I’m not sure why we even have Open, High Low Close in the ACC function, but changing that was the issue.

Also, you have a random “BACKTYPE” in the ACC function. It probably would do nothing wrong, but it does not need to be there.

I always like to break scripts up so I can see how the individual components are working. In this image I have your HIGH()>HIGHESTHIGH(BACKTYPE, BARS=22); as a Show Bar and the whole script above as a Show View. Then I can cast my eye back and see that any time the count at the bottom matches what I am seeing with the Show Bar.

Hope that helps

Mathew