【发布时间】:2021-08-10 02:13:45
【问题描述】:
我想为交易视图上的以下指标添加警报(开源,振荡器)。简而言之,必须满足多个条件才能触发不同类型的警报(多头进场、早出多头、晚出多头、空头进场、早出空头、晚空头离场)。我有三个因素,slowMA + fastMA + 基于 RSI 或移动平均线的中线(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'。参数的类型应该是:series[float]; 第 36 行:不能用 'y'=plot 调用'crossover'。参数的类型应该是:series[float]; 第 37 行:不能用 'x'=plot 调用'crossover'。参数的类型应该是:series[float]; 第 38 行:不能用 'x'=plot 调用'crossover'。参数的类型应该是:series[float]; 第 39 行:不能用 'x'=plot 调用'crossover'。参数的类型应该是:series[float]; 第 40 行:不能用 'y'=plot 调用'crossover'。参数的类型应该是:series[float]; 第 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')
【问题讨论】:
标签: pine-script