我想在交易视图(开源,振荡器)上向以下指标添加警报。简而言之,必须满足多个条件才能触发不同类型的警报(长进入、长退出早、长退出晚、短进入、短退出早、短退出晚)。我有三个因素,基于RSI或移动平均线的slowMA + fastMA +中线(midl)。
长条目: slowMA向上交叉fastMA + slowMA向上交叉midl + fastMA向上交叉midl
长时间提前退出: fastMA向上移动slowMA + slowMA向上移动midl + fastMA向上移动midl
迟迟未出: fastMA向上穿越slowMA + midl向上穿越slowMA + midl向上穿越fastMA
短文: FastMA向上穿越slowMA + midl向上穿越slowMA + midl向上穿越fastMA
提前短时间退出: slowMA向上穿越fastMA + midl向上穿越slowMA + midl向上穿越fastMA
短尾段退出: slowMA向上穿越fastMA + slowMA向上穿越midl + fastMA向上穿越midl
我以前根本没有编码经验。我收到下面的错误。非常感谢您的帮助!:
第35行:无法使用'y'=plot调用'crossover‘。该参数的类型应为: seriesfloat;第36行:不能使用'y'=plot调用'crossover‘。参数的类型应该是: seriesfloat;第37行:不能使用'x'=plot调用'crossover‘。参数的类型应该是: seriesfloat;第38行:不能使用'x'=plot调用'crossover‘。参数的类型应该是: seriesfloat;第39行:不能使用'x'=plot调用'crossover‘。参数的类型应该是: seriesfloat;第40行:不能使用'y'=plot调用'crossover‘。参数的类型应为: seriesfloat;第42行:未声明的标识符'longopen';行43:未声明的标识符'longcloseearly';行44:未声明的标识符'longcloselate';行45:未声明的标识符'shortopen';行46:未声明的标识符'shortcloseearly';行47:未声明的标识符'shortcloselate‘
//@version=4
study("TDI + RSI + BB [Market Makers Method]", shorttitle="MMM")
rsiPeriod = input(21, minval = 1, title = "RSI Period")
bandLength = input(34, minval = 1, title = "Band Length")
lengthrsipl = input(7, minval = 0, title = "Fast MA on RSI")
lengthtradesl = input(2, minval = 1, title = "Slow MA on RSI")
src = close // Source of Calculations (Close of Bar)
r = rsi(src, rsiPeriod) // RSI of Close
ma = sma(r, bandLength) // Moving Average of RSI [current]
offs = (1.6185 * stdev(r, bandLength)) // Offset
up = ma + offs // Upper Bands
dn = ma - offs // Lower Bands
mid = (up + dn) / 2 // Average of Upper and Lower Bands
fastMA = sma(r, lengthrsipl) // Moving Average of RSI 2 bars back
slowMA = sma(r, lengthtradesl) // Moving Average of RSI 7 bars back
hline(32) // ExtremelyOversold
hline(37) // Oversold
hline(50) // Midline
hline(63) // Overbought
hline(68) // ExtremelyOverbought
upl = plot(up, "Upper Band", color = #3286c3, linewidth = 2) // Upper Band
dnl = plot(dn, "Lower Band", color = #3286c3, linewidth = 2) // Lower Band
midl = plot(mid, "Middle of Bands", color = #ffff00, linewidth = 2) // Middle of Bands
plot(slowMA, "Slow MA", color = #00AB08, linewidth=2) // Plot Slow MA
plot(fastMA, "Fast MA", color = #ff0000, linewidth=1) // Plot Fast MA
longopen = crossover(slowMA, fastMA) and crossover(fastMA, midl) and crossover(slowMA, midl)
longcloseearly = crossover(fastMA, slowMA) and crossover(slowMA, midl) and crossover(fastMA, midl)
longcloselate = crossover(fastMA, slowMA) and crossover (midl, slowMA) and crossover(midl, fastMA)
shortopen = crossover(fastMA, slowMA) and crossover(midl, slowMA) and crossover(midl, fastMA)
shortcloseearly = crossover(slowMA, fastMA) and crossover(midl, slowMA) and crossover(midl, fastMA)
shortcloselate = crossover(slowMA, fastMA) and crossover(slowMA, midl) and crossover(fastMA, midl)
alertcondition(longopen, title='Long Open', message='Long Open')
alertcondition(longcloseearly, title='Long Close Early', message='Long Close Early')
alertcondition(longcloselate, title='Long Close Late', message='Long Close Late')
alertcondition(shortopen, title='Short Open', message='Short Open')
alertcondition(shortcloseearly, title='Short Close Early', message='Short Close Early')
alertcondition(shortcloselate, title='Short Close Late', message='Short Close Late')发布于 2021-08-10 04:03:43
Cannot call 'crossover' with 'y'=plot.表示您正在尝试使用函数crossover中的绘图,这是一个不兼容的选项:您应该将series[float]传递给它。
在crossover()函数中,尝试使用mid而不是midl,如下所示:
longopen = crossover(slowMA, fastMA) and crossover(fastMA, mid) and crossover(slowMA, mid) https://stackoverflow.com/questions/68720353
复制相似问题