策略:理解策略。exit()和stragity.close()。如何决定应该使用哪一个?

发布于 2025-01-26 13:58:43 字数 1263 浏览 2 评论 0原文

在我找到并建立了对我的理解的策略模板中,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡的优雅 2025-02-02 13:58:43

使用stragity.exit()当您要退出价格时,价格达到计算值(TP/SL)时。实际上,您必须至少具有以下参数之一:PROUTlimit损失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().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文