Pine 脚本未遍历所有点,仅保留一个入口且没有出口
查找以下 10 SMA 到 20 SMA 交叉的代码,该代码无法正常工作
//@version=5
strategy(' MA Crossover ', overlay=true)
start = timestamp(2007, 1, 1, 0, 0)
end = timestamp(2022, 03, 21, 0, 0)
ema1 = ta.sma(close, 10)
ema2 = ta.sma(close, 20)
plot(ema1, title='EMA 11', color=color.new(color.green, 0))
plot(ema2, title='EMA 20', color=color.new(color.blue, 0))
LongEntry = ta.crossover(ema1, ema2)
LongExit = ta.crossover(ema2, ema1)
strategy.entry('Long Entry', strategy.long, when=LongEntry)
strategy.close('Long Exit', when=LongExit)
Find below code for 10 SMA to 20 SMA crossover which is not working somehow
//@version=5
strategy(' MA Crossover ', overlay=true)
start = timestamp(2007, 1, 1, 0, 0)
end = timestamp(2022, 03, 21, 0, 0)
ema1 = ta.sma(close, 10)
ema2 = ta.sma(close, 20)
plot(ema1, title='EMA 11', color=color.new(color.green, 0))
plot(ema2, title='EMA 20', color=color.new(color.blue, 0))
LongEntry = ta.crossover(ema1, ema2)
LongExit = ta.crossover(ema2, ema1)
strategy.entry('Long Entry', strategy.long, when=LongEntry)
strategy.close('Long Exit', when=LongExit)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
strategy.close()
的第一个参数是id
。您需要传递您想要关闭的交易的 ID。在你的情况下应该是:
First parameter of
strategy.close()
isid
.You need to pass the id of the trade you want to close. In your case it should be: