TradingView Pinescript not closing the correct trade ID bug

https://www.youtube.com/watch?v=Q3vHXIJF4lU

As you can see in this video, I have set the condition for long and the condition for short, I entered with trade ID and set the exit limit the same as the entry ID, however on the list of trades, it doesn’t match the exit with the correct ID? For example how is it possible that Short Loss 2 is used to closed Short 1 when littertatly I put strategy.exit(Short 1) after strategy.entry(Short 1) ?? I hope this pinescript bug have a parameter I dont know of to fix this issue or else it the pinescript developers would need to actually fix this bug. What funny is Short 1 is matched with Short Loss 1 on the chart but NOT ON THE LIST OF trades. As you can see I calculated TP at 0.25% and SL 0.05% for each trade but due to Pinescript bug it show average winning trade 0.15% instead of 0.25%.

Here is the code for testing

//@version=5
strategy("Wrong ID Closed", overlay=true, initial_capital=2500, currency="USD", default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0, pyramiding=30, slippage=0, calc_on_every_tick=true, margin_long=0, margin_short=0)


volume_delta = input.int(500, title="Volume Delta",inline = "5")

useCustomTimeframeInput = input.bool(false, "Use custom timeframe")
lowerTimeframeInput = input.timeframe("1", "Timeframe")
float FixedTPPercent = 0.25/100 //0.20% FixedTPPercent
float FixedSLpercent = 0.05/100 //0.05% SL

tZone = input.string("UTC+3","Timezone",options = ["UTC-12", "UTC-11", "UTC-10", "UTC-9", "UTC-8", "UTC-7", "UTC-6", "UTC-5", "UTC-4", "UTC-3", "UTC-2", "UTC-1", "UTC+0", "UTC+1", "UTC+2", "UTC+3", "UTC+3:30", "UTC+4", "UTC+4:30", "UTC+5", "UTC+5:30", "UTC+5:45", "UTC+6", "UTC+6:30", "UTC+7", "UTC+8", "UTC+9", "UTC+9:30", "UTC+10", "UTC+10:30", "UTC+11", "UTC+11:30", "UTC+12", "UTC+12:45", "UTC+13", "UTC+14"])
timeinrange(TimeRange) => not na(time("1", TimeRange, tZone))

i_sess_1 = input.session("1000-1200", "Trading Session",inline = "1")
i_sess_2 = input.session("1500-1700", "Trading Session",inline = "2")


float ema_longest = ta.ema(close, 30)
float ema_medium = ta.ema(close, 15)
float ema_shortest = ta.ema(close, 14)

longCondition = ema_shortest > ema_medium  and ema_medium > ema_longest 
shortCondition = ema_shortest < ema_medium  and ema_medium < ema_longest


var int LongCount = 0
var int ShortCount = 0
//Volume Delta Calculator by Lux Algo*******************
upAndDownVolume() =>
    posVol = 0.0
    negVol = 0.0
    
    var isBuyVolume = true    

    switch
        close > open     => isBuyVolume := true
        close < open     => isBuyVolume := false
        close > close[1] => isBuyVolume := true
        close < close[1] => isBuyVolume := false

    if isBuyVolume
        posVol += volume
    else
        negVol -= volume

    posVol + negVol

var lowerTimeframe = switch
    useCustomTimeframeInput => lowerTimeframeInput
    timeframe.isseconds     => "1S"
    timeframe.isintraday    => "1"
    timeframe.isdaily       => "5"
    => "60"

diffVolArray = request.security_lower_tf(syminfo.tickerid, lowerTimeframe, upAndDownVolume())

getHighLow(arr) =>
    float cumVolume = na
    float maxVolume = na
    float minVolume = na

    for item in arr
        cumVolume := nz(cumVolume) + item
        maxVolume := math.max(nz(maxVolume), cumVolume)
        minVolume := math.min(nz(minVolume), cumVolume)

    [maxVolume, minVolume, cumVolume]

[maxVolume, minVolume, lastVolume] = getHighLow(diffVolArray)
openVolume = not na(lastVolume) ? 0.0 : na
//Volume Delta Calculator By Lux Algo ***********************************



if ((longCondition) and (timeinrange(i_sess_1) or timeinrange(i_sess_2)) and (lastVolume > volume_delta))
    LongCount += 1
    
    strategy.entry("Long " + str.tostring(LongCount), strategy.long)
    strategy.exit("Exit Long " + str.tostring(LongCount), "Long " + str.tostring(LongCount), limit = close + (close*FixedTPPercent), stop = close - (close*FixedSLpercent), comment_profit = "Long Profit " + str.tostring(LongCount), comment_loss = "Long loss " + str.tostring(LongCount))
    

if (shortCondition and (timeinrange(i_sess_1) or timeinrange(i_sess_2)) and (lastVolume < (-1 * volume_delta)))
    ShortCount += 1
    strategy.entry("Short " + str.tostring(ShortCount), strategy.short)
    strategy.exit("Exit Short " + str.tostring(ShortCount), "Short " + str.tostring(ShortCount), limit = close - (close*FixedTPPercent), stop = close + (close*FixedSLpercent), comment_profit = "Short Profit " + str.tostring(ShortCount), comment_loss = "Short Loss " + str.tostring(ShortCount))

For each entry, TP should be EXACTLY 0.25% away from entry and SL 0.05% away from ENTRY. But from Performance Summary, average winning trade % and average losing trade % say something different.

As seen in the code, an attempt to make each TP and SL seperate for each trade is made by using trade ID + str.tostring(tradeCount) in strategy.entry(), it should work but pinescript compiler bugged so it doesn’t work? It works perfectly on chart but not in the list of trades and performance summary.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật