2EMA与Renko图表上的箭头

时间:2019-12-18 00:41:55

标签: pine-script

我是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上方后,在下一个砖块上调用文本,并以其他方式通过将文本+红色箭头向下 Screenshot

有人知道我在做什么错吗?

1 个答案:

答案 0 :(得分:1)

查看代码中的注释:

//@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")

enter image description here

使用1分钟的Renko条形图并不像使用更长的时间范围那么糟糕,但仍然存在风险。这些链接可能有助于了解原因: https://www.tradingview.com/script/q9laJNG9-Backtesting-on-Non-Standard-Charts-Caution-PineCoders-FAQ/

https://www.tradingview.com/chart/?solution=43000480330

https://www.tradingview.com/chart/?solution=43000481029