简体   繁体   English

Pine Script - 如何 select 一个带有日期时间选择器的蜡烛条,并在此条的高点和低点绘制水平线

[英]Pine Script - How to select a candle stick bar with date time picker and draw horizontal lines at the high and low of this bar

I am trying to draw hline (horizontal lines) at the high and low of a candle stick bar (15 minute time frame is a MUST) which I have selected from date time picker.我正在尝试在我从日期时间选择器中选择的蜡烛条的高点和低点绘制 hline(水平线)(必须 15 分钟的时间范围)。 As of now I can select the bar and highlight its background color to confirm that the date time picker is working fine.截至目前,我可以 select 栏并突出显示其背景颜色以确认日期时间选择器工作正常。 However I cannot draw horizontal lines at the high and low of this selected bar.但是,我无法在此选定条的高点和低点绘制水平线。 The issue here is, I don't know how to get the high and low of the bar which I have selected from date time picker.这里的问题是,我不知道如何获取我从日期时间选择器中选择的栏的高点和低点。 Below is the code.下面是代码。

//@version=4
study("Price Channel with date range test", overlay=true)

i_startTime = input(defval = timestamp("06 May 2021 04:30 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("06 May 2021 04:45 +0000"), title = "End Time", type = input.time)

inDateRange = time >= i_startTime and time <= i_endTime
bgcolor(inDateRange ? color.lime : na, 90)

// Need code to get the high and low of this candle stick bar selected from the date time picker

Working Code.工作代码。

//@version=4
study("Price Channel with time range", overlay=true)

i_startTime = input(defval = timestamp("07 May 2021 04:30 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("07 May 2021 04:30 +0000"), title = "End Time", type = input.time)

inDateRange = time >= i_startTime and time <= i_endTime
bgcolor(inDateRange ? color.lime : na, 90)

var highe_01 = 0.0
var lowe_01  = 0.0

if inDateRange
    if not inDateRange[1]
        highe_01 := high
        lowe_01  := low
    else
        highe_01 := max(high, highe_01)
        lowe_01  := min(low, lowe_01)

plot(not inDateRange ? highe_01 : na, title="High", color=color.purple, linewidth=2, style=plot.style_linebr, offset=-9999, trackprice=true)
plot(not inDateRange ? lowe_01: na, title="Low",  color=color.purple,  linewidth=2, style=plot.style_linebr, offset=-9999, trackprice=true)

The below gives you the option of having the lines to either: just to the right or across the whole chart (tick box in settings).下面为您提供了将线条设置为以下任一选项的选项:仅在右侧或整个图表(设置中的复选框)。

Is this what you are after?这就是你所追求的吗?

//@version=4
study("Price Channel with time range", overlay=true)

i_startTime = input(defval = timestamp("07 May 2021 04:30 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("07 May 2021 04:30 +0000"), title = "End Time", type = input.time)

inDateRange = time >= i_startTime and time <= i_endTime
bgcolor(inDateRange ? color.lime : na, 90)

var highe_01 = 0.0
var lowe_01  = 0.0

if inDateRange
    if not inDateRange[1]
        highe_01 := high
        lowe_01  := low
    else
        highe_01 := max(high, highe_01)
        lowe_01  := min(low, lowe_01)

//plot(not inDateRange ? highe_01 : na, title="High", color=color.purple, linewidth=2, style=plot.style_linebr)
//plot(not inDateRange ? lowe_01: na, title="Low",  color=color.purple,  linewidth=2, style=plot.style_linebr)

///////////////////////////////

showHigh = input(true, title="High", group="High Line", inline="1")
showLow = input(true, title="Low", group="Low Line", inline="1")

ExtendAxisLine = input(false, title="Extend lines across screen")
ExtendOption = ExtendAxisLine ? extend.both : extend.right

HighDateLine = (not inDateRange ? highe_01 : na)
var line ShowHighLine = na
if showHigh
    ShowHighLine := line.new(bar_index[1], HighDateLine, bar_index, HighDateLine, color=color.yellow, style=line.style_dashed, width=1, extend=ExtendOption)    
    line.delete(ShowHighLine[1])    

LowDateLine = (not inDateRange ? lowe_01 : na)
var line ShowLowLine = na
if showLow
    ShowLowLine := line.new(bar_index[1], LowDateLine, bar_index, LowDateLine, color=color.yellow, style=line.style_dashed, width=1, extend=ExtendOption)    
    line.delete(ShowLowLine[1])    

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在特定蜡烛的松树脚本上绘制水平线? - How can i draw the horizontal lines on pine script for particular candle? 如何在松树脚本中找到蜡烛的日高/低 - How to find the candle has day high / low in pine script 如何在 1 分钟字符时间范围内在 9.30 蜡烛的高点和低点形成 plot 水平线 - How to plot horizontal lines on high and low of the 9.30 candle in 1minute char time frame 如何在 Pine Script 中绘制 MA 水平线 - How to draw MA horizontal lines in Pine Script 如何在 Pine Script 中找到之前单个蜡烛 x 柱的值 - How to find the value of a single candle x bar before in Pine Script 在松树脚本中填充柱线的低点/高点下方/上方的订单 - Fill order below/above the low/ high of the bar in pine script 在 Pine Editor 中,如何在 session 的最后一根柱的高低上画一条线,并将其延伸到下一个 session 的最后一根? - How can I Draw a line on high and low of last bar of a session, and extend it to the last bar of next session, in Pine Editor? Pine Script 中第一根蜡烛的高点和低点之间的点数 - Number of pips between high and low of First Candle in Pine Script Pine Script v4 - 如何在前一根柱线的高点/低点设置止损? - Pine Script v4 - How do I set a stop loss at a previous bar's high/low? 如何在指定时间范围内为我的条形高点和 pine 编辑器中图表的 session 创建水平线 - How can a create horizontal line for my bar high on a specified time frame and session of the chart in pine editor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM