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

Categories

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

pine script - Identify Name of Month and ID First Trading Day of Month on Day Chart

I have a Tradingview Pinescript script for identifying day of week. I would like to add ability to identify name of month, is that possible?

//@version=4

study(title = "Day of Week & Open - Intraday", shorttitle = "Day of Week", overlay=true)

// Get User input - which time label to show
showDOPEN       = input(true, title="Identify Daily Open - 5PM EST")
showDOW         = input(true, title="Identify Days of Week - Midnight EST")

BarInSession(sess) =>
    not na(time(timeframe.period, sess))
    
// 5PM EST. *Sun open identified which is also Mondays bar open
dayOpen =   time(timeframe.period,"1700-1659")
plotshape(showDOPEN ? hour == 17 and minute == 0 and dayofweek == dayofweek.sunday : false, title="Mon Open", text="MO", color=color.aqua, location=location.belowbar, style=shape.triangleup, textcolor=color.aqua, size=size.tiny, transp=10)
plotshape(showDOPEN ? hour == 17 and minute == 0 and dayofweek == dayofweek.monday : false, title="Tue Open", text="TO", color=color.aqua, location=location.belowbar, style=shape.triangleup, textcolor=color.aqua, size=size.tiny, transp=10)
plotshape(showDOPEN ? hour == 17 and minute == 0 and dayofweek == dayofweek.tuesday : false, title="Wed Open", text="WO", color=color.aqua, location=location.belowbar, style=shape.triangleup, textcolor=color.aqua, size=size.tiny, transp=10)
plotshape(showDOPEN ? hour == 17 and minute == 0 and dayofweek == dayofweek.wednesday : false, title="Thur Open", text="RO", color=color.aqua, location=location.belowbar, style=shape.triangleup, textcolor=color.aqua, size=size.tiny, transp=10)
plotshape(showDOPEN ? hour == 17 and minute == 0 and dayofweek == dayofweek.thursday : false, title="Fri Open", text="FO", color=color.aqua, location=location.belowbar, style=shape.triangleup, textcolor=color.aqua, size=size.tiny, transp=10)

// Midnight EST - Day of Week
plotshape(showDOW ? hour == 0 and minute == 0 and dayofweek == dayofweek.monday : false, title="Mon", text="M", color=color.green, style=shape.diamond, textcolor=color.green, size=size.tiny, transp=10)
plotshape(showDOW ? hour == 0 and minute == 0 and dayofweek == dayofweek.tuesday : false, title="Tue", text="T", color=color.green, style=shape.diamond, textcolor=color.green, size=size.tiny, transp=10)
plotshape(showDOW ? hour == 0 and minute == 0 and dayofweek == dayofweek.wednesday : false, title="Wed", text="W", color=color.green, style=shape.diamond, textcolor=color.green, size=size.tiny, transp=10)
plotshape(showDOW ? hour == 0 and minute == 0 and dayofweek == dayofweek.thursday : false, title="Thur", text="R", color=color.green, style=shape.diamond, textcolor=color.green, size=size.tiny, transp=10)
plotshape(showDOW ? hour == 0 and minute == 0 and dayofweek == dayofweek.friday : false, title="Fri", text="F", color=color.green, style=shape.diamond, textcolor=color.green, size=size.tiny, transp=10)

Thanks.


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

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...