首页 > 解决方案 > Pine Script:如何获取特定时间的 OHLC 数据?

问题描述

我想获取一天中特定时间的 OHLC 数据。比方说,我想要每天下午 12 点的 OHLC,我该如何在 Pine Script 中做到这一点?

标签: pine-script

解决方案


尝试这个:

(请注意,它不会在高于每日的时间范围内工作)

哦,当然可以TIMEZONE_OFFSET根据您所在的位置进行编辑

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © marketscripters

//@version=4
study("My Script", overlay=true)

HOUR_TO_CHECK = 12
TIMEZONE_OFFSET = -4

hourCheck = HOUR_TO_CHECK - TIMEZONE_OFFSET

var float val = na

if hour[1] < hourCheck and hour >= hourCheck
    val := ohlc4

plot(val)

推荐阅读