pinescript-在特定时间范围内以最低的价格绘制Hline

发布于 2025-01-17 09:37:38 字数 423 浏览 1 评论 0原文

我能够在主图表中的特定时间(ex.10:00)创建一个hline的hline。如果我想以1分钟图中的时间范围的最低价格(例如10:00-10:05)创建Hline,该怎么办?

//@version=5
indicator("My Script", overlay=true)

_h = 10  // Hour: 10
_m = 0  // Minute: 0
inWindow = (hour(time) == _h) and (minute(time) == _m)
var line l = na
if (inWindow)
    l := line.new(bar_index, low, bar_index + 1, low, extend=extend.right, color=color.orange, width=2)
    line.delete(l[1])

I was able to create a Hline on price low at a specific time (ex.10:00) in the main chart. How should I go about if I wanted to create a Hline at the lowest price of a time range (say 10:00 - 10:05) in a 1min chart?

//@version=5
indicator("My Script", overlay=true)

_h = 10  // Hour: 10
_m = 0  // Minute: 0
inWindow = (hour(time) == _h) and (minute(time) == _m)
var line l = na
if (inWindow)
    l := line.new(bar_index, low, bar_index + 1, low, extend=extend.right, color=color.orange, width=2)
    line.delete(l[1])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

番薯 2025-01-24 09:37:38

您可以使用 input.session() 获取时间范围,并使用 time() 查看您是否处于选定的时间窗口内。

//@version=5
indicator("My script", overlay=true)

time_window = input.session("0900-1500", "Session")

is_in_window = time(timeframe.period, time_window + ":1234567")

var float _lowest = na

if is_in_window
    if (not is_in_window[1])
        _lowest := low
    else
        _lowest := math.min(low, _lowest)
else
    _lowest := na

plot(_lowest, "Lowest", color.red, 1, plot.style_circles)

输入图片此处描述

You can use the input.session() to get the time frame and time() to see if you are in the selected time window.

//@version=5
indicator("My script", overlay=true)

time_window = input.session("0900-1500", "Session")

is_in_window = time(timeframe.period, time_window + ":1234567")

var float _lowest = na

if is_in_window
    if (not is_in_window[1])
        _lowest := low
    else
        _lowest := math.min(low, _lowest)
else
    _lowest := na

plot(_lowest, "Lowest", color.red, 1, plot.style_circles)

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文