如何解决如何在一个脚本中创建多个单独的多头进场和多头离场订单
我想弄清楚如何在一个脚本中创建多个多头订单。
例如,我将一个具有 3 个买入/卖出条件的脚本放在一起,我希望每个脚本都有自己的进入/退出参数。弄清楚如何在一个脚本中对多个 Long 条目进行排序是我目前的障碍。
目前有“主要”、“快速”和“成交量”策略。
无论我尝试什么,这些都是独立工作的,但是当一起运行时,最快的一个基本上可以运行所有内容。也许 100 倍中的一个会漏掉,然后有时不同的策略会卖出/做多该交易,而不是让购买它的策略决定何时卖出。
我尝试过的方法包括嵌套循环和 strategy.oca 组。我一直在查看文档,但没有一个文档能展示我的场景——我发现的场景是多个入口和一个大出口。我希望每个策略都能自己进入和退出。我在 3 点进行金字塔计算。我尝试使用 Strategy.position_size == 0 条目,并尝试添加一个变量来阻止条件条件在已经有订单的情况下进行排序,但我尝试过的一切都不起作用。
如果重要,我不会使用任何保证金。
if OrderLong and not OrderShort
strategy.cancel(id="Sell")
strategy.entry(id="Buy",long=true,comment="Buy") //strategy.entry(id="Buy",stop=high,comment="Buy",limit=(OrderLimit))
if OrderShort and not OrderLong and not OrderShortFast
strategy.cancel(id="Buy")
strategy.exit("Sell","Buy",stop=low,limit=(OrderLimit),comment="Sell")
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if OrderLongFast and not OrderShortFast
strategy.cancel(id="SellFast")
strategy.entry(id="BuyFast",comment="Buy Fast") //strategy.entry("BuyFast",comment="Buy Fast",limit=(OrderLimit))
if OrderShortFast and not OrderShort
strategy.cancel(id="BuyFast")
strategy.exit("SellFast","BuyFast",comment="Sell Fast")
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if OrderLongVol
strategy.cancel(id="SellVol")
strategy.entry(id="BuyVol",comment="Buy Vol") //strategy.entry("BuyFast",limit=(OrderLimit))
if OrderShortVol
strategy.cancel(id="BuyVol")
strategy.exit("SellVol","BuyVol",comment="Sell Vol")
解决方法
您是否在 close_entries_rule = "ANY"
调用中使用了 strategy()
参数?
https://kodify.net/tradingview/strategy-settings/close-entries-rule/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。