![](/img/trans.png)
[英]how to write a buy or sell trigger after a number of bars meet condition which in my case is 2 renko bars above a certain EMA
[英]2EMA with arrows on Renko chart
我是 Pine Script 的新手,我只是想创建一个小脚本,但是它失败了,我只是不明白为什么。
//@version=3
study(title="2EMA cross", shorttitle="2EMA cross", overlay=true)
EMA1 = input(2, minval=1, title="EMA1")
EMA2 = input(5, minval=1, title="EMA2"),
long = EMA1[1] > EMA2[1]
short = EMA2[1] > EMA1[1]
//Use these alerts to create server-side alerts (right-click on one of the buy or sell arrows on the chart and choose "add alert")
alertcondition(long, title='Buy Call', message='EMA long reversal')
alertcondition(short, title='Buy Put', message='EMA short reversal')
//EMA COLORS
plot(ema(close, EMA1), color=green, linewidth=2)
plot(ema(close, EMA2), color=red, linewidth=2)
//Use this to customize the look of the arrows to suit your needs.
plotshape(long, location=location.belowbar, color=lime, style=shape.arrowup, text="Call")
plotshape(short, location=location.abovebar, color=red, style=shape.arrowdown, text="Put")
这是我得到的消息:
line 14: Cannot call `ema` with arguments (series, series[integer]); available overloads: ema(series, integer) => series;
line 15: Cannot call `ema` with arguments (series, series[integer]); available overloads: ema(series, integer) => series
我想要做的就是:绿色箭头向上 + 在快速 ema 越过慢速 ema 后在下一个砖块上调用文本,其他方式与 Put text + 红色箭头向下
有谁知道我做错了什么?
查看代码中的注释:
//@version=3
study(title="2EMA cross", shorttitle="2EMA cross", overlay=true)
// These are only your ema periodds—not the emas themselves.
EMA1 = input(2, minval=1, title="EMA1")
EMA2 = input(5, minval=1, title="EMA2")
// Create the two ema calculations here and then use the results to detect signals and plot.
ema1 = ema(close, EMA1)
ema2 = ema(close, EMA2)
// Detect only the moment when the 2 emas cross, otherwise you would be getting one of the two signals at any given moment.
// Note that detecting occurs at the bar following the actual cross.
long = crossover(ema1, ema2)
short = crossunder(ema1, ema2)
// Use these alerts to create server-side alerts (right-click on one of the buy or sell arrows on the chart and choose "add alert")
alertcondition(long, title='Buy Call', message='EMA long reversal')
alertcondition(short, title='Buy Put', message='EMA short reversal')
// EMA COLORS
plot(ema1, color=green, linewidth=2)
plot(ema2, color=red, linewidth=2)
// Use this to customize the look of the arrows to suit your needs.
plotshape(long, location=location.belowbar, color=lime, style=shape.arrowup, text="Call")
plotshape(short, location=location.abovebar, color=red, style=shape.arrowdown, text="Put")
使用 1 分钟 Renko 柱不像使用更长的时间框架那么糟糕,但它仍然有风险。 这些链接可能有助于理解原因: https : //www.tradingview.com/script/q9laJNG9-Backtesting-on-Non-Standard-Charts-Caution-PineCoders-FAQ/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.