如何使用 Pine 脚本为 TradingView 创建累积报价
How to create cumulative tick using Pine Script for TradingView
我正在尝试为日内交易创建基于 NYSE Tick 的累积直方图。累计指标应在每天 9:30am 时重置为零。到目前为止,我已经创建了累积直方图,但我不知道如何将其重置为零。谁能帮忙?
study(title="NYSE Ticks")
x = security ("TICK.NY", period, close)
c = x > x[1] ? green : red
cti = cum(x)
plot(cti,style=histogram,color=c,linewidth=4)
我是 Pine Script 的第一天新手。我也搜索过类似的主题,但在风向标中。请帮忙。
这使用 time()
function with session information 来检测图表的柱状图是否在要求的时间段内。
您的代码现在是 v4:
//@version=4
study(title="NYSE Ticks")
resetTime = input("0930-1000", "Reset time", input.session)
x = security ("TICK.NY", timeframe.period, close)
// Returns non `na` value when in session.
trigger = not na(time(timeframe.period, resetTime))
// Detect when reset time is hit.
reset = trigger and not trigger[1]
var cti = 0.
cti := reset ? 0. : cti + x
c = x > x[1] ? color.green : color.red
plot(cti, "cti", c, 4, plot.style_histogram)
// For debugging.
bgcolor(reset ? color.silver : na)
我正在尝试为日内交易创建基于 NYSE Tick 的累积直方图。累计指标应在每天 9:30am 时重置为零。到目前为止,我已经创建了累积直方图,但我不知道如何将其重置为零。谁能帮忙?
study(title="NYSE Ticks")
x = security ("TICK.NY", period, close)
c = x > x[1] ? green : red
cti = cum(x)
plot(cti,style=histogram,color=c,linewidth=4)
我是 Pine Script 的第一天新手。我也搜索过类似的主题,但在风向标中。请帮忙。
这使用 time()
function with session information 来检测图表的柱状图是否在要求的时间段内。
您的代码现在是 v4:
//@version=4
study(title="NYSE Ticks")
resetTime = input("0930-1000", "Reset time", input.session)
x = security ("TICK.NY", timeframe.period, close)
// Returns non `na` value when in session.
trigger = not na(time(timeframe.period, resetTime))
// Detect when reset time is hit.
reset = trigger and not trigger[1]
var cti = 0.
cti := reset ? 0. : cti + x
c = x > x[1] ? color.green : color.red
plot(cti, "cti", c, 4, plot.style_histogram)
// For debugging.
bgcolor(reset ? color.silver : na)