How can I limit a trigger to only one trade

Viewed 20

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

1 Answers

I solved it by using:

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

Variable id2 is the trade setup condition.

Related