Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
310 views
in Technique[技术] by (71.8m points)

pine script - Add trendline at 0000 NY on open candle

I would like to add a trendline at the NY 0000 time open candle. This would extend to 0500 NY time.

I found this code Plotting a horizontal ray at the daily open on tradingview but it plots it on the session changeover. Also this is a horizontal ray, I would like this to just be a trend line that extends from the open candle to 0500 NY time.

question from:https://stackoverflow.com/questions/66066459/add-trendline-at-0000-ny-on-open-candle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Based off https://forex.timezoneconverter.com/?timezone=UTC&refresh=5 I have set it to 1300. The below should help.

I have also added New York Weekly Open to the code.

//@version=4
study("New York Open Daily Weekly", overlay=true)

offset_val = input(title="Label Offset", type=input.integer, defval=30)


NYDOpenInput = input('1300-1301:134567', title="New York Daily Open") //set the opening range you are interested in

NYWOpenInput = input('1300-1301:2', title="New York Weekly Open") //set the opening range you are interested in

NYDOpen = time("1", NYDOpenInput)
NYWOpen = time("1", NYWOpenInput)


var NYDOpenPA = 0.0
if NYDOpen
    if not NYDOpen[1]
        NYDOpenPA := open

var NYWOpenPA = 0.0
if NYWOpen
    if not NYWOpen[1]
        NYWOpenPA := open



plot(not NYDOpen ? NYDOpenPA : na, title="New York D Open", color=color.blue, linewidth=1, style=plot.style_linebr)

plotshape(NYDOpenPA, style=shape.labeldown, location=location.absolute, color=color.blue,  textcolor=color.white, show_last=1, text="New York D Open",  offset = offset_val, transp=20, title="New York D Open")

plot(not NYWOpen ? NYWOpenPA : na, title="New York W Open", color=color.blue, linewidth=2, style=plot.style_linebr)

plotshape(NYWOpenPA, style=shape.labeldown, location=location.absolute, color=color.blue,  textcolor=color.white, show_last=1, text="New York W Open",  offset = offset_val, transp=20, title="New York W Open")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...