'The Target specified in strategy.exit is not working in the below Pinescript code

The Targets specified in "strategy.exit" is not working in the below Pinescript code. Please pardon if too many errors- this is my 1st Pinescript code.Please help.

Basically, the exit targets specified in the strategy.exit line are not computing.

//@version=5
strategy("MyFirstCode") 
var int numBars = 1
var bool isLong=false
var bool isShort=false
var int countTriggered = 0
t = time('D')
if t == t[1]
    numBars := nz(numBars[1]) + 1
    buyPoint=ta.highest(numBars)
    sellPoint=ta.lowest(numBars)
    cond1= numBars>9
    cond2= numBars<19
    cond3= buyPoint>high[numBars-1]
    cond4= sellPoint<low[numBars-1]
    cond5= close>low[numBars-1]
    cond6= close<high[numBars-1]
    cond7= not isLong
    cond8= not isShort
    entryCond= cond1 and cond2 and cond3 and cond4 and cond5 and cond6 and cond7 and cond8
    if entryCond 
        countTriggered := nz(countTriggered[1])+1
        if countTriggered==1
            rangeHigh=buyPoint
            rangeLow=sellPoint
            rnge=buyPoint-sellPoint
            slLong=sellPoint-0.50
            slShort=buyPoint+0.50
            tgtLong=0.95*rnge+buyPoint
            tgtShort=sellPoint-0.95*rnge
            strategy.entry("Long",strategy.long, stop=buyPoint+0.05, oca_name="x", oca_type=strategy.oca.cancel,when= countTriggered==1)
            strategy.entry("Short",strategy.short, stop=sellPoint-0.05, oca_name="x", oca_type=strategy.oca.cancel,when= countTriggered==1)
            strategy.exit("Long Exit",from_entry="Long", limit=tgtLong, stop=slLong,when= countTriggered==1)
            strategy.exit("Short Exit",from_entry="Short", limit=tgtShort, stop=slShort,when= countTriggered==1)
    isLong  := (strategy.position_size > 0)
    isShort := (strategy.position_size < 0)
    strategy.cancel_all(numBars==72 and (isLong or isShort))
    strategy.close("Long",numBars==72 and isLong)
    strategy.close("Short",numBars==72 and isShort)
else
    numBars := 1
    isLong :=false
    isShort :=false
    countTriggered :=0


Sources

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

Source: Stack Overflow

Solution Source