Bar Count

Hi team,

Is there any function can count how many bars was exceeded by today’s close?
Thank you for your help.

Regards.
Donald

Hi Donald,

If I understand your query correctly, the following counts the number of bars since the close was this low, ie today’s close in XLU has been exceeded by the previous 18 bars. Is that what you meant?

V1 = CLOSE();
//Get the latest value of V1;
V2=LAST(V1);
//Get count since V1<V2;
TIMESINCESIGNAL(V1<V2, Unit=Bars)

Capture

Dear Darren,

Thank you very much!!!

Regards.
Donald.

Hi Darren,

If i have condition like today’s close is 20 new days high(close), then count how many bar was exceeded by today’s close?
Can i do that on this way?

Please help, thank you!

Donald.

Hi Donald,

You could run a HighestHigh scan set to 20 days, and then open the results in a watchlist and add the following to a column to get the number of days since that close was exceeded.

V1 = CLOSE();
//Get the latest value of V1;
V2=LAST(V1);
//Get count since V1<V2;
TIMESINCESIGNAL(V1>V2, Unit=Bars)

So there were 73 stocks in the S&P500 with a new closing 20D high yesterday identified by the scan. Adding the above calculates a 3,710 day closing high for HWM and a 1,371 day high for GE. Note that those with a new all-time high will have a value of -1 (eg AAPL). Is that what you mean?

Image