Strategy Table Library
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © only_fibonacci

//@version=5

// @description TODO: With this library, you can add tables to your strategies.
library("table_library", overlay=true)


// @returns Strategy Profit Table
// Adds a table to the graph of the strategy for which you are calling the function. You can see data such as net profit in this table.
export strategy_table() =>
	//-----------TABLE
	// COLUMNS
    var table tablo = table.new(position.top_right,2,6,border_width=4,border_color=color.gray, frame_color=color.gray, frame_width=4)
    table.cell(tablo,0,0,bgcolor=color.black,text_color=color.white, text="NET PROFIT")
    table.cell(tablo,0,1,bgcolor=color.black,text_color=color.white, text="TOTAL PROFIT")
    table.cell(tablo,0,2,bgcolor=color.black,text_color=color.white, text="TOTAL LOSS")
    table.cell(tablo,0,3,bgcolor=color.black,text_color=color.white, text="PROFIT FACTOR")
    table.cell(tablo,0,4,bgcolor=color.black,text_color=color.white, text="WIN TRADES")
    table.cell(tablo,0,5,bgcolor=color.black,text_color=color.white, text="LOSS TRADES")
    // ROWS
    table.cell(tablo,1,0,bgcolor=strategy.netprofit>0 ? color.green : color.red,text_color=color.white, text=str.tostring(strategy.netprofit))
    table.cell(tablo,1,1,bgcolor=color.black,text_color=color.white, text=str.tostring(strategy.grossprofit))
    table.cell(tablo,1,2,bgcolor=color.black,text_color=color.white, text=str.tostring(strategy.grossloss))
    table.cell(tablo,1,3,bgcolor=strategy.grossprofit / strategy.grossloss >1 ? color.green : color.red,text_color=color.white, text=str.tostring(strategy.grossprofit / strategy.grossloss))
    table.cell(tablo,1,4,bgcolor=color.black,text_color=color.white, text=str.tostring(strategy.wintrades))
    table.cell(tablo,1,5,bgcolor=color.black,text_color=color.white, text=str.tostring(strategy.losstrades))
    tablo