Search code examples
pine-scriptpine-script-v5

How can I limit a trigger to only one trade


How to limit a trigger to only one trade/entry, and after an exit not generate another entry from the same trigger?


Solution

  • I solved it by using:

    b = ta.barssince(id2)
    tradesActively = ((strategy.closedtrades - strategy.closedtrades[b]) < 1)
    

    Variable id2 is the trade setup condition.