var float loLows = na
is_new_position = (strategy.position_size[1] != strategy.position_size) // This will only be true on the bar of the entry
loLows := is_new_position // Only update the value if it is a new position. Keep the old value otherwise
TPL=(strategy.position_avg_price/RR)-(loLows/RR)+strategy.position_avg_price
TPS=(strategy.position_avg_price/RR)-(hiHighs/RR)-strategy.position_avg_price
if inDateRange and (close > (ema200) and close > (ema992) and ta.crossover(ema13,ema62) and ta.crossover(ema21,ema62)) strategy.entry("entry long", strategy.long) strategy.exit("long exit", profit=TPL, stop=loLows)
if inDateRange and(close < (ema200) and close < (ema992) and ta.crossunder(ema13,ema62) and ta.crossunder(ema21,ema62)) strategy.entry("entry short", strategy.short) strategy.exit("short exit", profit=TPS , stop=hiHighs)