Pine脚本版本变更及停止重印重画问题

问题描述 投票:0回答:1

这是一个非常小的松树脚本,遵循趋势,但我面临着重新绘制和重新打印的问题。

//@version=2

strategy("PrabhuTrendStrategy", overlay=true)

tim=input('160')

out1 = security(tickerid, tim, open)
out2 = security(tickerid, tim, close)

plot(out1,color=red)
plot(out2,color=green)

longCondition = crossover(security(tickerid, tim, close),security(tickerid, tim, open))

if (longCondition)
    strategy.entry("long", strategy.long)

shortCondition = crossunder(security(tickerid, tim, close),security(tickerid, tim, open))

if (shortCondition)
    strategy.entry("short", strategy.short)
pine-script version pine-script-v5 repaint strategy-pattern
1个回答
0
投票

//@version=2
中,
lookahead
参数设置为
barmerge.lookahead_on
,这将导致重新绘制。

将您的代码升级到

v5
并使用以下函数来实现共享的非重画安全功能这里

// Function to securely and simply call `security()` so that it never repaints and never looks ahead.
f_secureSecurity(_symbol, _res, _src) => request.security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)
© www.soinside.com 2019 - 2024. All rights reserved.