Untitled

 avatar
unknown
plain_text
2 months ago
1.8 kB
4
Indexable
// PNL ve sayaçlar
pnl = strategy.closedtrades.profit(strategy.closedtrades - 1) 

var int loss_count = na      
var int max_loss_count = na  
var int profit_count = na    
var int max_profit_count = na 

// PNL değiştiğinde 
if ta.change(pnl) != 0 
    if pnl < 0  
        loss_count := nz(loss_count, 0) + 1  
        profit_count := 0  
         
        if loss_count > nz(max_loss_count, 0) 
            max_loss_count := loss_count 
             
    else if pnl > 0  
        profit_count := nz(profit_count, 0) + 1  
        loss_count := 0  
         
        if profit_count > nz(max_profit_count, 0) 
            max_profit_count := profit_count 
             
    else  
        loss_count := 0 
        profit_count := 0 

// TABLO OLUŞTURMA
var table stats_table = table.new(position.top_right, 3, 4, color.black, border_width=1)

// Tablo başlıkları
table.cell(stats_table, 0, 0, "Metrik", bgcolor=color.gray, text_color=color.white)
table.cell(stats_table, 1, 0, "Mevcut", bgcolor=color.gray, text_color=color.white)
table.cell(stats_table, 2, 0, "Maksimum", bgcolor=color.gray, text_color=color.white)

// Tablo içeriğini güncelle
table.cell(stats_table, 0, 1, "Ardışık Zarar", text_color=color.red)
table.cell(stats_table, 1, 1, str.tostring(loss_count), text_color=color.red)
table.cell(stats_table, 2, 1, str.tostring(max_loss_count), text_color=color.red)

table.cell(stats_table, 0, 2, "Ardışık Kar", text_color=color.green)
table.cell(stats_table, 1, 2, str.tostring(profit_count), text_color=color.green)
table.cell(stats_table, 2, 2, str.tostring(max_profit_count), text_color=color.green)

table.cell(stats_table, 0, 3, "PNL", text_color=color.white)
table.cell(stats_table, 1, 3, str.tostring(pnl), text_color = pnl >= 0 ? color.green : color.red)
Editor is loading...
Leave a Comment