我想看看谁可以帮助我编写一个我不能让它以我想要的方式工作的代码。我不是程序员,但我一直在看教程,但我没有得到我想要的东西。我会附上一些图像,这样你就可以直观地知道我想做什么。

现在我附加了一张图片,其中我指出了我要寻找的东西

现在解释一下第二张图片:如图1所示,背景颜色和高低线不像第二张图片那样填充。我的想法是背景颜色是长方体的形式,如果不是如图2所示,则不会像图1中看到的那样好。就像高线和低线匹配背景颜色一样,假设我使用的时间范围是07:00到17:00,我会留下代码和我应该使用的配置,希望有人能帮助我,谢谢!
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
study("High & Low Of Custom Session", shorttitle="High/Low Of Custom Session",overlay=true)
// Inputs
my_session = input("0700-1700", type=input.session, title='Custom Session')
Lines = input(true, title="Show High/Low Lines?")
FILL = input(true, title="Show Session BGcolor?")
// Determine if we are in a session
in_session = time(timeframe.period, my_session)
is_new_session(res, sess) =>
t = time(res, sess)
na(t[1]) and not na(t) or t[1] < t
new_session = is_new_session("0600", my_session)
// Start of Session
is_newbar(res,sess) =>
t = time(res,sess)
not na(t) and (na(t[1]) or t > t[1])
new = (is_newbar("0600", my_session) ? 1 : 0)
// Plot Start Of Session
col_Start_of_Session = new_session and new==1? color.aqua:na
// In Session High/Low Calculations
var float _low = low
var float _high = high
_low := new_session? low : in_session ? min(low, _low[1]) : na
_high := new_session ? high : in_session ? max(high, _high[1]) : na
col_low = _low == low? na: Lines?color.red:na
col_high = _high== high? na:Lines? color.green:na
// Plot High/Low Line
Low=plot(_low, style=plot.style_line, linewidth=1, color=col_low)
High=plot(_high, style=plot.style_line, linewidth=1, color=col_high)
// BG Color
Fill_col = FILL ? color.aqua:na
fill(Low,High, color=Fill_col)
//
// End of Session
start_of_session_value = valuewhen((new==1),high,0)
end_session_condition = start_of_session_value !=start_of_session_value[1]?0: in_session?1:0
end_session = (end_session_condition == 0) and (end_session_condition[1]==1)? color.orange:na发布于 2020-11-19 21:43:43
你所要求的在Pine是做不到的。
但是,您可以使用line对象使这两条线从同一条形图开始。
下面是一个简单的例子:
var l1 = line.new(na, na, na, na, color=color.yellow)
var l2 = line.new(na, na, na, na, color=color.yellow)
if barstate.islast
line.set_xy1(l1, bar_index-10, 1880)
line.set_xy2(l1, bar_index, 1880)
line.set_xy1(l2, bar_index-10, 1890)
line.set_xy2(l2, bar_index, 1890)不幸的是,您不能使用line对象来创建fill()。
不能使用plot()同时启动这些行的原因是,事先不知道high/low,并且在过去不能使用plot()。
您可以通过使用带有参数lookahead=barmerge.lookahead_on的security()函数来绕过历史会话的限制。将检索“future”值的。
但是对于今天的会话,您无法做到这一点,因为在会话关闭之前,该会话的high/low是未知的。
所以,总而言之,你必须在以下两者之间做出选择:
plot()并且具有fill()背景,但是线条不会同时开始。line对象并且具有线条同时开始,但是没有背景色fill()编辑:要使用的代码
这将绘制您想要的内容,但它不会在正在创建新的高点/低点的实时会话中画出一条直线。然而,所有的历史会议都会有直线。
//@version=4
study("Lookahead", overlay=true)
var float daily_high = na
var float daily_low = na
newSession = change(time("D"))
[hi,lo] = security(syminfo.ticker, "D", [high,low], lookahead=barmerge.lookahead_on)
plot_color = newSession ? na : color.green
fill_color = newSession ? na : color.gray
plot_hi = plot(hi, "High", color=plot_color)
plot_lo = plot(lo, "Low", color=plot_color)
fill(plot_lo, plot_hi, fill_color, 60)这将产生以下输出

编辑:可配置为仅在开始和结束时间之间绘制的代码。
//@version=4
study("Lookahead", overlay=true)
var session_info = input("0700-1700", "Plot between these hours", input.session)
var float daily_high = na
var float daily_low = na
newSession = change(time("D"))
inSession = time(timeframe.period, session_info)
[hi,lo] = security(syminfo.ticker, "D", [high,low], lookahead=barmerge.lookahead_on)
plot_color = newSession ? na : color.green
fill_color = newSession ? na : color.gray
plot_hi = plot(inSession ? hi : na, "High", plot_color, style=plot.style_linebr)
plot_lo = plot(inSession ? lo : na, "Low", plot_color, style=plot.style_linebr)
fill(plot_lo, plot_hi, fill_color, 60)https://stackoverflow.com/questions/64911715
复制相似问题