簡體   English   中英

Pine 腳本停止和限制堆棧問題

[英]Pine Script Stop and Limit Stack issue

我想知道有人可以幫助闡明我在下面的 strategy.exit 函數中哪里出錯了。 我一直在繞圈子,進一步弄亂代碼並重新開始嘗試讓它正常工作。

strategy.exit(id="TrailingStop", qty_percent = 100, stop=stopprice, alert_message = close_cmd)

strategy.exit(id="TP", limit=tp, qty_percent = 50, comment= "50%", alert_message = tp_cmd)

我有 2 個出口,1 個跟蹤止損 100% 的 position 和 1 個止盈/限價 50%

似乎由於訂單的原因,我只能讓一個工作而不是另一個。 如果我先設置追蹤止損,那么它會關閉 100%,但會損失止盈,但是如果我先編寫 TP,那么止損只會關閉 50% 的交易有沒有辦法將它們寫在同一個策略中。退出 function同時保留不同的 %s 和警報消息? 還是一種將追蹤止損編碼為 strategy.close 指令的方法?

一定有辦法寫一個 100% 的追蹤止損和一個 50% 的限價單?

嘗試這個

strategy.exit(id="TP", limit=tp, qty_percent = 50, comment= "50%", alert_message = tp_cmd)
strategy.exit(id="TrailingStop", qty_percent = 100, limit=tp, stop=stopprice, alert_message = close_cmd)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM