0

I am writting a script based on a strategy that worked perfectly on calculations and also on backtest. Now once the code was done I realyzed that strategy.entry() function reverts the position but I expected to open an independet position on the opposite direction. Exemple:

bla, bla, bla... strategy.extry(id = "buy", direction = strategy.long, qty = 1) bla, bla, bla... strategy.entry(id = "hedgesell",direction = strategy.short, qty = 1)

I expected to have two different positions, one Long and another Short but instead Pine Script reverses the Long position to a Sell position increasing it size.

I understand that I can create an indicator and trigger alerts to the exchange and open/close shorts and longs, but is there any way to make it work on a strategy? This would be nice 'cause I could "re-backtest" and make the automation easier.

Thanks in advance for the ones who can give me a hand!

1 Answers1

0

Hedging is not supported on Tradingview. If you don't want to convert it to an indicator, you can create two strategies, one for long only and one for short only. Then you need to compare the results.

vitruvius
  • 15,740
  • 3
  • 16
  • 26