'strategy.exit exiting all orders at arbitrary point even with independent pts/stop losses (pyramiding)

So this is a follow-up from my previous question. I've tried to utilize some arrays to create multiple buy, profit taking and stop orders so that trades can be open and closed independently (I sometimes have 6+ orders open at once). ie: I have an independent stop and profit targets for multiple separate buy order instead of them being averaged in or both being closed at once. My issue is that for some reason they are all closing on one arbitrary candle and I have no idea why. I have printed labels to show the contents of my arrays and they all appear correct. Any help would be really appreciated. Let me know if you need any more info. Thanks! My code for the arrays and opening/exiting positions is as follows. Note - I also have pyramiding set at 10 so it's not being exceeded.

if (tradeSignal and bullishEC and bullishM and barstate.isconfirmed and inSession(timezone) and inDateRange)
    array.push(buyPos, close)
    array.push(longStop, low)
    array.push(longTarget, close + ((close - low)*2))
    strategy.entry(id="long", long=strategy.long, qty=1)

    for i = 0 to array.size(buyPos) - 1
        lblText1 := tostring(array.get(buyPos, i))
        lblText2 := tostring(array.get(longStop, i))
        lblText3 := tostring(array.get(longTarget, i))
    lblT1 = label.new(x=bar_index, y=432, text=lblText1, yloc=yloc.price, color=color.yellow)
    lblT2 = label.new(x=bar_index, y=na, text=lblText2, yloc=yloc.belowbar, color=color.red)
    lblT3 = label.new(x=bar_index, y=na, text=lblText3, yloc=yloc.abovebar, color=color.green)


if strategy.position_size > 0
    for i = 0 to array.size(buyPos) - 1// loop through every element in the array to check if stop or pt is hit
        if (low < array.get(longStop, i)) 
            strategy.exit("id=exit", from_entry="long", stop=array.get(longStop, i), qty=1) 
            lblText5 = tostring(low)
            lblPos5 = label.new(x=bar_index, y=na, text=lblText5, yloc=yloc.belowbar, color=color.blue)
        if (high > array.get(longTarget, i))

Here is what the chart looks like: chart



Sources

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

Source: Stack Overflow

Solution Source