I have TP and SL based on ATR value at entry moment. I have pyramiding option turned on, but then, all open at specific time trades (that are in the same direction: long or short) close at the same moment, all together. How to make every trade independent and how to make every trade being closed on a set at entry TP or SL.
Ps. TP = 2ATR, SL = 1ATR
Ps 2. Pine script version5
Similar problem here: Pyramiding trades with independent take profit (Pinescript)
My code for Long trades:
ATR = ta.atr(14)
if EntryLongCondiction1 and EntryLongCondiction2
strategy.entry("Long", strategy.long)
lastLongEntryPrice = strategy.opentrades.entry_price(strategy.opentrades - 1)
var float LongProfit = na
var float LongStop = na
if (strategy.position_size[1] != strategy.position_size)
LongProfit := lastLongEntryPrice + (ATR * 2)
LongStop := lastLongEntryPrice - (ATR * 1)
strategy.exit("Long", stop=LongStop, limit=LongProfit)