Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

pine script - 1st day of Month/Year market open times

Afternoon all,

I am using the below to capture the open time for London Daily and Weekly (the time can be changed for other markets(London, New York, Asia).

But what do I use in replacement for:

LonDOpenInput = input('0800-0801:134567', title="London Daily Open")

To capture 1st day of month (specific time) and 1st day of year (specific time):

//@version=4
study("Help (Timed Open)", overlay=true)

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

LonDOpenInput = input('0800-0801:134567', title="London Daily Open") //set the opening range you are interested in
LonWOpenInput = input('0800-0801:2', title="London Weekly Open") //set the opening range you are interested in


LonDOpen = time("1", LonDOpenInput)
LonWOpen = time("1", LonWOpenInput)


var LonDOpenPA = 0.0
if LonDOpen
    if not LonDOpen[1]
        LonDOpenPA := open

var LonWOpenPA = 0.0
if LonWOpen
    if not LonWOpen[1]
        LonWOpenPA := open


plot(not LonDOpen ? LonDOpenPA : na, title="London D Open", color=color.yellow, linewidth=1, style=plot.style_linebr)
plotshape(LonDOpenPA, style=shape.labeldown, location=location.absolute, color=color.yellow,  textcolor=color.white, show_last=1, text="London D Open",  offset = offset_val, transp=20, title="London D Open")

plot(not LonWOpen ? LonWOpenPA : na, title="London W Open", color=color.yellow, linewidth=2, style=plot.style_linebr)
plotshape(LonWOpenPA, style=shape.labeldown, location=location.absolute, color=color.yellow,  textcolor=color.white, show_last=1, text="London W Open",  offset = offset_val, transp=20, title="London W Open") 
question from:https://stackoverflow.com/questions/65940621/1st-day-of-month-year-market-open-times

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

1 Answer

0 votes
by (71.8m points)

Think I have worked it out. Seems to work when applied to the chart. Any comments.

LonYOpen = year == 2021 and month == 1 and dayofmonth == 1 and hour == 08 and minute == 00


NYYOpen = year == 2021 and month == 1 and dayofmonth == 1 and hour == 13 and minute == 00

AsiaYOpen = year == 2021 and month == 1 and dayofmonth == 1 and hour == 23 and minute == 00


var LonYOpenPA = 0.0
if LonYOpen
    if not LonYOpen[1]
        LonYOpenPA := open
//    else
//        LonWOpenPA := max(open, LonWOpenPA)


var NYYOpenPA = 0.0
if NYYOpen
    if not NYYOpen[1]
        NYYOpenPA := open
//    else
//        NYWOpenPA := max(open, NYWOpenPA)


var AsiaYOpenPA = 0.0
if AsiaYOpen
    if not AsiaYOpen[1]
        AsiaYOpenPA := open
//    else
//        AsiaWOpenPA := max(open, AsiaWOpenPA)



plot(not LonYOpen ? LonYOpenPA : na, title="London Y Open", color=color.purple, linewidth=4, style=plot.style_linebr)
plotshape(LonYOpenPA, style=shape.labeldown, location=location.absolute, color=color.purple,  textcolor=color.white, show_last=1, text="London Y Open",  offset = offset_val, transp=20, title="London Y Open")

plot(not NYYOpen ? NYYOpenPA : na, title="New York Y Open", color=color.purple, linewidth=4, style=plot.style_linebr)
plotshape(NYYOpenPA, style=shape.labeldown, location=location.absolute, color=color.purple,  textcolor=color.white, show_last=1, text="New York Y Open",  offset = offset_val, transp=20, title="New York Y Open")

plot(not AsiaYOpen ? AsiaYOpenPA : na, title="Asia Y Open", color=color.purple, linewidth=4, style=plot.style_linebr)
plotshape(AsiaYOpenPA, style=shape.labeldown, location=location.absolute, color=color.purple,  textcolor=color.white, show_last=1, text="Asia Y Open",  offset = offset_val, transp=20, title="Asia Y Open")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...