Last 90 days a new Highest High

How can I program this:
close reached within in the last 90 days a new historic high.

HH = Close > Highest(High);
HHTimeframe = BarsSince(Close > HH );
Cond = HHTimeframe < 91 ;  

Can someone show me that. Thanks.

In your code you do a few mistakes.

First of all Close can not be higher than Highest H since it includes current bar's high.
(For example same mistake has been done just few minutes ago in a different thread)

So you have to add Ref()

HH = Highest(High);
HHcond = Close > Ref(HH, -1);

Secondly in HHTimFrame you compare price level with true/false condition.
So instead you should do this (since BarsSince expects true/false):

HH = Highest(High);
HHcond = Close > Ref(HH, -1);
HHTimeframe = BarsSince(HHcond);

Now check results in Exploration

HH = Highest(High);
HHcond = Close > Ref(HH, -1);
HHTimeframe = BarsSince(HHcond);
Cond = HHTimeframe < 91;  

Filter = Cond;

AddColumn(Close, "Close", 1.2);
AddColumn(Ref(HH,-1), "Ref(HH,-1)", 1.2);
AddColumn(HHTimeframe, "Bars since Cond", 1 );
7 Likes

Thanks for the help.:smiley::smiley::smiley:

@Munichtrader - you should not mark your own post as solution but @fxshrat post because it is his post that gives the solution (I marked it already).

3 Likes