在我找到并建立了我的理解的策略模板中,strategy.exit()
和strategy.close()
都包含在strategy.entry()
之后,但是在手册中只有一个,参见下面:
Strategy.Exit
//@version=5
strategy(title = "simple strategy exit example")
strategy.entry("long", strategy.long, 1, when = open > high[1]) // enter long by market if current open great then previous high
strategy.exit("exit", "long", profit = 10, loss = 5) // generate full exit bracket (profit 10 points, loss 5 points per contract) from entry with name "long"
Strategy.Close
//@version=5
strategy("closeEntry Demo", overlay=false)
strategy.entry("buy", strategy.long, when = open > close)
strategy.close("buy", when = open < close, qty_percent = 50, comment = "close buy entry for 50%")
plot(strategy.position_size)
如何决定在特定情况下应该使用哪一种?他们都应该被使用吗?哪一个是干什么用的?
我可以看到,strategy.exit()
有更多的参数需要指定。
strategy.exit(id, from_entry, qty, qty_percent, profit, limit, loss, stop, trail_price, trail_points, trail_offset, oca_name, comment, when, alert_message) → void
strategy.close(id, when, comment, qty, qty_percent, alert_message) → void
如果我没有错,我可能更喜欢strategy.exit()
,…?
发布于 2022-05-04 21:17:55
当价格达到计算值(TP/SL)时,请使用strategy.exit()
。实际上,您必须至少有以下参数之一:profit
、limit
、loss
、stop
,否则它会引发错误。
若要以市场价格关闭该头寸,请使用strategy.close()
。
https://stackoverflow.com/questions/72116271
复制相似问题