Plot horizontal line at subsequent higher highs from a starting date?

M

Minefieldhopscotch

New member
VIP
Hi, this is a request for help with creating a study. I have simple scripting skills and I haven't been able to figure this out on my own. I would like to be able to plot a horizontal line on a chart from an inputted start date at that day's high. Then on subsequent days when the stock's high is higher, shift the horizontal line higher to that new high value. The line at the highs would move higher as the stock's prior high is exceeded, but the line would never move lower. Below is a link to a mock-up sketch on imgur.com that illustrates what I am trying to do. The way I want to use this is as a way to easily visualize how closely or not a stock is trending upward near its highs. Thanks very much.

 
RobertPayne

RobertPayne

Member
Ruby:
input StartDate = 20191003;
def hh = if GetYYYYMMDD() == StartDate then high else if high > hh[1] then high else hh[1];
plot higherHigh = if GetYYYYMMDD() < StartDate then Double.NaN else hh;
higherHigh.SetPaintingStrategy(12);

 
Last edited:

Similar threads

Top