简体   繁体   中英

Pine Script strategy.exit multiple TP and SL not working

I'm working on a strategy with multiple take profit and stop loss. Once I opened a trade I tried to set initial stop loss and take profit. Then if trade management setting is turned on, I also want to set partial tp1 and tp2. But for now only entry and the first exit code are working in strategy. The reset are not working in strategy settings. I also set close_entries_rule to 'ANY' as I found in another thread but it didn't help. See the screenshot of strategy panel
Any thoughts on what I'm missing?

 strategy(....close_entries_rule="ANY")
    
    strategy.entry('S', strategy.short, limit=close)
    strategy.exit('S SL', 'S', stop=shortSL)
    strategy.exit('S TP', 'S', limit = shortTP)        
       if useTradeMgmt
           strategy.exit('S TP1', 'S', qty_percent=tp1percent, limit=tp1Price)
           strategy.exit('S TP2', 'S', qty_percent=tp2percent, limit=tp2Price)
  1. partial exit must be before full
  2. if you want to protect by stop loss partial exits too, specify it too
    strategy.entry('S', strategy.short, limit=close)
       if useTradeMgmt
           strategy.exit('S TP1', 'S', qty_percent=tp1percent, limit=tp1Price, stop=shortSL)
           strategy.exit('S TP2', 'S', qty_percent=tp2percent, limit=tp2Price, stop=shortSL)
    strategy.exit('S SL', 'S', stop=shortSL, limit = shortTP)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM