Number bars (days) since 52 week high


Category:
0
0

Hi Pete, is it possible to create a watch list Colum to show  number of bars (days ) since 52week high, if is possible to exclude todays bar,  in other words if  52 week high was 10 days ago and today there’s a new 52 week high the Colum should keep showing 10 instead of 0 … hopefully that make sense.   Thanks for your time Pete.

Marked as spam
Posted by (Questions: 8, Answers: 23)
Asked on March 17, 2021 11:38 pm
216 views
0
Private answer

The following code will produce the bar count to the most recent highest high within the period defined by user input named "barsAgo":

input barsAgo = 251;
plot data = GetMaxValueOffset(high[1], barsAgo);

You will find that if the chart is showing two or more consecutive highest highs within the "barsAgo" period the count will drop to zero. (so to consecutive highest highs will show as zero). The count will restart as soon as the next bar plots a lower high than previous.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on March 18, 2021 8:35 am
0
Thanks Pete works great!
( at March 18, 2021 9:02 am)