pine-script - Pine 回测,如果已经打开了一个新交易,则不会打开一个新交易
问题描述
标题说明了一切,这是我的代码。
strategy.entry("Short", strategy.short, comment="InsBarSE")
strategy.exit("Short", loss=200, profit=200, when=exit_long)
strategy.entry("Long", strategy.long, comment="InsBarLE")
strategy.exit("Long", loss=200, profit=200, when=exit_short)
很多时候,空头交易会自动关闭多头交易,我不希望这种情况发生,我希望他们一直走下去,直到达到盈利或亏损,请帮助。
解决方案
您没有使用该from_entry=
参数进行strategy.exit()
调用,因此他们正在退出任何未平仓交易。有关详细信息,请参阅裁判员。您的代码应如下所示:
strategy.entry("Short", strategy.short, comment="InsBarSE")
strategy.exit("Exit Short", "Short", loss=200, profit=200, when=exit_long)
strategy.entry("Long", strategy.long, comment="InsBarLE")
strategy.exit("Exit Long", "Long", loss=200, profit=200, when=exit_short)
推荐阅读
- c# - 如何在数据绑定的复选框列表中隐藏某些值
- python - 使用 python 通过 websocket 连接到 ActiveMQ STOMP
- java - java中的setPeekHeight()与xml中的结果不同
- java - Jsp如何将选定的值传递给servlet?
- c++ - 在 C++ 中使用类型为 CPerson(类)的对象初始化 STL 向量?
- python - 使用 Python 的枕头/PIL 库:
- javascript - 调用变量的方法并在达到阈值之前停止循环
- javascript - Angular 5 如何设置最小延迟(或超时)?
- typescript - Ionic 3 中的 InApp 购买 - 如何实现用户之间的支付?
- javascript - 在下一个 div 和另一个 remove 上处于活动状态