[英]Why does PineScript tells me that my TEMA is not a function?
[英]Why does this Pinescript alert repaint, despite having refactored the security function?
我只是无法解决您发布的任何功能的问题。 我正在尝试消除对应用于图表的指标的重新绘制,该图表的时间框架为 15m,需要将其设置为 1h:
//@version=4
res5 = input("60", type=input.resolution)
// Funzione di security incapsulata
f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src, barmerge.gaps_off, barmerge.lookahead_on)[1]
// Funzioni di security
o = f_secureSecurity(syminfo.tickerid, res5, open)
c = f_secureSecurity(syminfo.tickerid, res5, close)
hz = f_secureSecurity(syminfo.tickerid, res5, high)
l = f_secureSecurity(syminfo.tickerid, res5, low)
////////////////////////////////////////////////////////////////////////////////
// INPUT SUPERTREND
st_mult = input(0.1, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)
st_period = input(50, title = 'SuperTrend Period', minval = 1)
// CALCULATIONS //
up_lev =l - (st_mult * atr(st_period))
dn_lev = hz + (st_mult * atr(st_period))
up_trend = 0.0
up_trend := c[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev
down_trend = 0.0
down_trend := c[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev
// Calculate trend var
trend = 0
trend := c > down_trend[1] ? 1: c < up_trend[1] ? -1 : nz(trend[1], 1)
// Calculate SuperTrend Line
st_line = trend ==1 ? up_trend : down_trend
////////////////////////////////////////////////////////////////////////////////
// CONDIZIONI DI INGRESSO A MERCATO
OpenLong = crossover(c, st_line)
OpenShort = crossunder(c, st_line)
CloseLong = OpenShort
CloseShort = OpenLong
////////////////////////////////////////////////////////////////////////////////
// SEGNALI DI DEBUG
OpenLongFlag = if OpenLong == true
1
else
0
OpenShortFlag = if OpenShort == true
1
else
0
CloseLongFlag = if CloseLong == true
1
else
0
CloseShortFlag = if CloseShort == true
1
else
0
plot(OpenLongFlag, color = color.black)
plot(OpenShortFlag, color = color.yellow)
plot(CloseLongFlag, color = color.blue)
plot(CloseShortFlag, color = color.red)
////////////////////////////////////////////////////////////////////////////////
// ALLERT
alertcondition(OpenLong,title="Open Long")
alertcondition(CloseLong,title="Close Long")
alertcondition(OpenShort,title="Open Short")
alertcondition(CloseShort,title="Close Short")code here
警报的生成时间与我在 Tradingview 图表中输入的调试信号不同,然后它们被重新绘制。
您之前发布的封装函数(f_secureSecurity)是否可能在如此短的时间范围内不起作用?
尝试这个:
...
f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src[1], barmerge.gaps_off, barmerge.lookahead_on)
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.