在TradingView中,Pine脚本函数策略。如果单独设置盈利和停止损失而不是单行,则无法工作

发布于 2025-01-19 11:06:26 字数 400 浏览 1 评论 0原文

当我尝试设置止损和止盈水平时,以下代码适用于我:

strategy.exit("TP/SL 1", "Long Entry 1",  stop = long_stop_level,  limit = long_profit_level)

但此代码的问题是它不会告诉我这是止损退出或止盈退出。所以我尝试将其拆分按照以下方式进行:

strategy.exit("SL 1", "Long Entry 1",  stop = long_stop_level)
strategy.exit("TP 1", "Long Entry 1",  limit = long_profit_level)

但我注意到只有止损起作用,而止盈不起作用,无论如何我可以解决这个问题吗?

The following code works for me when I try to set the stop loss and take profit level:

strategy.exit("TP/SL 1", "Long Entry 1",  stop = long_stop_level,  limit = long_profit_level)

But the issue for this code is that it will not tell me it is a stop loss exit or take profit exit.. so I tried to split it off to the following manner:

strategy.exit("SL 1", "Long Entry 1",  stop = long_stop_level)
strategy.exit("TP 1", "Long Entry 1",  limit = long_profit_level)

But I notice that only the stop loss is working but not the take profit, is there anyway I could fix that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

北方的巷 2025-01-26 11:06:26

用这个。并将显示在图表 SL 和 TP 上。请注意,我使用的是 v5

strategy.exit("exit Long", from_entry="Long",loss= sl,profit = tp,comment_profit="Buy TP", comment_loss="Buy SL")

use this. and it will display on chart SL and TP. Note that i'm using v5

strategy.exit("exit Long", from_entry="Long",loss= sl,profit = tp,comment_profit="Buy TP", comment_loss="Buy SL")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文