如何在图表中画线?
How to draw a line in the chart?
enter image description here
如图所示,当天的前三支蜡烛。
您基本上是在问加注范围。
这将把时间作为输入并绘制水平线与那个时期的高点和低点,所以如果你在 15m TF 上并且你想要获得 3 根蜡烛的更高的高点和最低的低点,将它设置为45 分钟 (15 * 3 = 45)...等等。
不是你画的正方形,而是你问的。
//@version=4
study("My Script - Opening range", overlay=true)
// Inputs
my_session = input("0930-1015", type=input.session, title='Custom Session')
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("1440", 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("1440", my_session) ? 1 : 0)
// Plot Start Of Session
col_Start_of_Session = new_session and new==1? color.aqua:na
//plotshape(high, color=col_Start_of_Session, style=shape.circle, location= location.absolute, size=size.small, title="Start_of_Session")
// In Session High/Low Calculations
var float _low = close
var float _high = close
_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: true?color.red:na
col_high = _high== high? na:true? 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.new(color.yellow, 70):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
//plotshape(close, color=end_session, location=location.absolute, style=shape.circle, size=size.small)
// Extend High/Low Session Lines
v_extend_low = valuewhen((_low == low),low,0)
col_v_extend_low = (end_session_condition == 0) and v_extend_low ==v_extend_low[1] ? color.red:na
v_extend_high = valuewhen((_high == high),high,0)
col_v_extend_high = (end_session_condition == 0) and v_extend_high ==v_extend_high[1] ? color.green:na
plot(v_extend_low, color=col_v_extend_low, title="Extend Low")
plot(v_extend_high, color=col_v_extend_high, title="Extend High")
enter image description here
如图所示,当天的前三支蜡烛。
您基本上是在问加注范围。 这将把时间作为输入并绘制水平线与那个时期的高点和低点,所以如果你在 15m TF 上并且你想要获得 3 根蜡烛的更高的高点和最低的低点,将它设置为45 分钟 (15 * 3 = 45)...等等。
不是你画的正方形,而是你问的。
//@version=4
study("My Script - Opening range", overlay=true)
// Inputs
my_session = input("0930-1015", type=input.session, title='Custom Session')
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("1440", 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("1440", my_session) ? 1 : 0)
// Plot Start Of Session
col_Start_of_Session = new_session and new==1? color.aqua:na
//plotshape(high, color=col_Start_of_Session, style=shape.circle, location= location.absolute, size=size.small, title="Start_of_Session")
// In Session High/Low Calculations
var float _low = close
var float _high = close
_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: true?color.red:na
col_high = _high== high? na:true? 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.new(color.yellow, 70):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
//plotshape(close, color=end_session, location=location.absolute, style=shape.circle, size=size.small)
// Extend High/Low Session Lines
v_extend_low = valuewhen((_low == low),low,0)
col_v_extend_low = (end_session_condition == 0) and v_extend_low ==v_extend_low[1] ? color.red:na
v_extend_high = valuewhen((_high == high),high,0)
col_v_extend_high = (end_session_condition == 0) and v_extend_high ==v_extend_high[1] ? color.green:na
plot(v_extend_low, color=col_v_extend_low, title="Extend Low")
plot(v_extend_high, color=col_v_extend_high, title="Extend High")