【发布时间】:2020-06-15 17:11:26
【问题描述】:
在 pine-script 中找到以下内容,但不确定它是否是错误,或者是否在我没有注意到的文档中提及它。
代号 GOLD
这行得通:
//@version=4
strategy("My Script",overlay=true, process_orders_on_close=true)
if (time > timestamp(2020, 02, 28,0,0,0))
strategy.entry("buy", strategy.long, comment = "Long")
Stop1 = 18.03
Stop2 = 16.5
if (low < Stop1)
strategy.cancel_all()
strategy.close_all(comment = "STOP1")
else if (low < Stop2)
strategy.cancel_all()
strategy.close_all(comment = "STOP2")
但是,这不起作用(仓位没有关闭)
//@version=4
strategy("My Script",overlay=true, process_orders_on_close=true)
plot(close)
if (time > timestamp(2020, 02, 28,0,0,0))
strategy.entry("buy", strategy.long, comment = "Long")
Stop1 = 18.03
Stop2 = 16.5
if (low < Stop1)
strategy.cancel_all()
strategy.close_all(comment = "STOP1")
if (low < Stop2)
strategy.cancel_all()
strategy.close_all(comment = "STOP2")
我预计,在第二个版本中,“STOP2”会取消“STOP1”并继续平仓,但是似乎没有下订单。
如果我做错了什么,请告诉我,以便我知道它会继续前进。我的代码行为异常,我花了很长时间才缩小范围:)
谢谢!
在进一步研究之后,我认为它与小数有关。 这有效:
Stop1 = 16.5
Stop2 = 18.3
.. 但这不起作用
Stop1 = 16.5
Stop2 = 18.03
【问题讨论】:
标签: pine-script