策略:理解策略。exit()和stragity.close()。如何决定应该使用哪一个?
在我找到并建立了对我的理解的策略模板中,exit.exit()
and strategy.close()
在stragity.entry()< /code>,但在手册中,只有其中一个,请参见下面:
stragity.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"
策略。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)
如何决定在某种情况下应使用哪种?应该使用它们吗?哪一个是为什么?
我可以看到stragity.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
我可能更喜欢stragity.exit()
如果我没有错……?
In a strategy template I found and established my understanding on, both strategy.exit()
and strategy.close()
are included after strategy.entry()
but in the manual, there's only one of them, see below:
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)
How to decide which should be used in a certain case? Should they both be used? Which one is for what?
I can see that strategy.exit()
has more arguments to be specified.
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
I may prefer strategy.exit()
if I'm not wrong…?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
stragity.exit()
当您要退出价格时,价格达到计算值(TP/SL)时。实际上,您必须至少具有以下参数之一:PROUT
,limit
,损失
,stop
或否则它将丢弃错误。要以市场价格关闭头寸,请使用
stragity.close()
。Use
strategy.exit()
when you want to exit when the price reaches to a calculated value (TP/SL). In fact, you must have at least one of the following parameters:profit
,limit
,loss
,stop
or else it will throw an error.To close the position at market price, use
strategy.close()
.