'In tradingview, pine script function strategy.exit doesn't work if take profit and stop loss were set separately instead of a single line

The following code works for me when I try to set the stop loss and take profit level:

strategy.exit("TP/SL 1", "Long Entry 1",  stop = long_stop_level,  limit = long_profit_level)

But the issue for this code is that it will not tell me it is a stop loss exit or take profit exit.. so I tried to split it off to the following manner:

strategy.exit("SL 1", "Long Entry 1",  stop = long_stop_level)
strategy.exit("TP 1", "Long Entry 1",  limit = long_profit_level)

But I notice that only the stop loss is working but not the take profit, is there anyway I could fix that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source