[英]Pinescript multiple strategy.exit for one entry
我嘗試為一個條目創建兩個不同的 strategy.exit function(其中一個用於限制,另一個用於停止)。 因為我想從這兩個出口 function 獲得不同的意見。
相關代碼片段:
strategy.entry("Longi" , direction = strategy.long, limit = close + 5)
strategy.exit("LongKapa" , from_entry = "Longi" , limit = xxx)
strategy.exit("LongKapa" , from_entry = "Longi" , stop = xxx)
但是策略測試員忽略了第二個。 那么如何在 if 塊中不使用 strategy.order 來獲得兩個不同的評論呢?
你應該給它唯一的 id,否則你將modify
而不是create
一個新的。
strategy.entry("Longi" , direction = strategy.long, limit = close + 5, qty=2)
strategy.exit("LongKapa-1" , from_entry = "Longi" , limit = xxx, qty=1)
strategy.exit("LongKapa-2" , from_entry = "Longi" , stop = xxx, qty=1)
https://www.tradingview.com/pine-script-reference/v5/#fun_strategy{dot}退出
使用邏輯or
。 適用於boolean個表達式。
longCondition = ta.crossunder(ta.sma(close, 20), ta.sma(close, 50))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
exitCondition = ta.crossunder(ta.sma(close, 10), ta.sma(close, 20)) or ta.crossunder(ta.sma(close, 10), ta.sma(close, 50))
if (exitCondition)
strategy.exit("exit", "My Long Entry Id", profit = 10, loss = 5)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.