简体   繁体   中英

I am needing to plot a line in pinescript with values ranging from 0-100 in a dictionary, for each day

I am needing to plot a line in pinescript with values ranging from 0-100 in a dictionary, for each day.

For example, August 1 I want the line to be at 40, august 2-35, august 3-38, etc.. This would be a series of entries that I manually update each day. I apologize for the basic question, but I am not a very experienced programmer. Thanks

I am needing to plot a line in pinescript with values ranging from 0-100 in a dictionary, for each day.

TradingView currently doesn't have a dictionary feature. But what you can do is create a series of conditional operators that compare each day. Then when the day is say August 2, store 35 in a variable (which we then later plot on the chart).

An example of that approach is:

//@version=3
study(title="Example script", overlay=true)

aug18 = (year == 2018) and (month == 8)

plotValue = aug18 and (dayofmonth == 1) ? 40 :
     aug18 and (dayofmonth == 2) ? 35 :
     aug18 and (dayofmonth == 3) ? 38 :
     na // default

plot(series=plotValue, linewidth=2, style=linebr)

I know this isn't a perfect solution: a real dictionary feature would be much easier to work with. But this is one of the best alternatives currently possible in TradingView.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM