Position Sizer v2.1 - Risk & Trade Planning Tool

Ray_Burst · study · 363 行 · 点赞 80 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Ray_Burst
 
//@version=6
indicator("⭐️ Position Sizer v2.1", overlay=true)
 
// POSITION SIZER
 
P_Sizer_Button = input.bool(true, "Show Pos.Sizer")
 
time_i = input.time(defval=timestamp("Sep 20 2026 00:00:00"), title="• From:", confirm=true, inline="3", group="Running Period & plotting preferences")
 
bgcolor(time[1] < time_i and time >= time_i ? color.new(color.orange, 50) : na)
 
Timezone_Input = input.string(defval="Europe/Rome", title="• Time Zone:", options=["Europe/Rome", "UTC", "Europe/London", "Europe/Berlin", "Europe/Paris", "Europe/Madrid", "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", "America/Toronto", "America/Sao_Paulo", "Asia/Dubai", "Asia/Kolkata", "Asia/Singapore", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Tokyo", "Australia/Sydney", "Exchange"], group="Running Period & plotting preferences", tooltip="Time zone used to display Entry Date and End Date. Europe/Rome automatically handles CET/CEST daylight-saving changes.")
 
Display_TZ = Timezone_Input == "Exchange" ? syminfo.timezone : Timezone_Input
 
Selected_SIDE = input.string("Long", "Chose Trading SIDE", options=["Long", "Short"], inline="1", group="Position Sizer")
TP_Mode = input.string("Fixed RR", "Take Profit Mode", options=["Fixed RR", "Fixed TP"], inline="TPMODE", group="Position Sizer")
Balance = input.float(defval=50000, title="Set        Balance", inline="2", group="Position Sizer")
Risk_perc = input.float(defval=2, title="Set       [%] Risk", inline="2", group="Position Sizer", step=0.1) / 100
Entry_p = input.price(defval=50000, title="Set    Entry Price", inline="3", group="Position Sizer")
Exit_p = input.price(defval=49000, title="Set       SL Price", inline="3", group="Position Sizer")
TP = input.price(defval=55000, title="Set Fixed TP Price", inline="4", group="Position Sizer")
set_RR = input.float(defval=3, step=0.25, title="Set Fixed RR", inline="4", group="Position Sizer")
f_ASS = input.float(defval=0.045, title="Set C,D-EX [%] fee", inline="5", group="Position Sizer") / 100
CONT_Tolerance = input.float(defval=0.0001, title="Set CONT-Tolerance", minval=0.00000001, group="Position Sizer", tooltip="Minimum executable quantity step. The theoretical Coin Size is always rounded DOWN to the nearest multiple of this value.")
 
// ============================================================================
// FUNCTIONS
// ============================================================================
 
f_datetime(int ts) =>
    na(ts) ? "n/a" : timeframe.isintraday ? str.format_time(ts, "dd/MM/yyyy HH:mm", Display_TZ) : str.format_time(ts, "dd/MM/yyyy", Display_TZ)
 
f_elapsed(int ms) =>
    int safe_ms = ms < 0 ? 0 : ms
    int d = int(math.floor(safe_ms / 86400000))
    int rem_d = safe_ms - d * 86400000
    int h = int(math.floor(rem_d / 3600000))
    int rem_h = rem_d - h * 3600000
    int m = int(math.floor(rem_h / 60000))
    d > 0 ? str.tostring(d) + "d " + str.tostring(h) + "h " + str.tostring(m) + "m" : h > 0 ? str.tostring(h) + "h " + str.tostring(m) + "m" : str.tostring(m) + "m"
 
// ============================================================================
// TAKE PROFIT ENGINE
// ============================================================================
 
TP_on_RR = Selected_SIDE == "Long" ? Entry_p + set_RR * (Entry_p - Exit_p) : Entry_p - set_RR * (Exit_p - Entry_p)
TP_active = TP_Mode == "Fixed RR" ? TP_on_RR : TP
 
// ============================================================================
// REPLAY-SAFE CLOCK ENGINE
// ============================================================================
 
bool Live_Clock_OK = barstate.isrealtime and timenow >= time and (na(time_close) or timenow <= time_close)
int Bar_Reference_Time = Live_Clock_OK ? timenow : na(time_close) ? time : time_close
 
// ============================================================================
// TRADE PRICE CONDITIONS
// ============================================================================
 
bool Entry_hit = time >= time_i and low <= Entry_p and high >= Entry_p
bool SL_hit = Selected_SIDE == "Long" ? low <= Exit_p : high >= Exit_p
bool TP_hit = Selected_SIDE == "Long" ? high >= TP_active : low <= TP_active
 
// ============================================================================
// TRADE STATE ENGINE
// ============================================================================
 
var bool Trade_Entered = false
var bool Trade_Closed = false
var int Trade_Result = 0
var int Trade_Entry_Time = na
var int Entry_Count_Start = na
var int Trade_Close_Time = na
var int Trade_Close_Exposure_Time = na
 
bool Entry_Triggered_This_Bar = time >= time_i and not Trade_Entered and not Trade_Closed and Entry_hit
 
if Entry_Triggered_This_Bar
    Trade_Entered := true
    Trade_Entry_Time := Live_Clock_OK ? timenow : time
    Entry_Count_Start := Bar_Reference_Time
 
if time >= time_i and Trade_Entered and not Trade_Closed
    if SL_hit
        label.new(x=bar_index, y=Exit_p, yloc=yloc.price, text="❌", textcolor=color.red, color=na, style=label.style_none, size=size.large)
        Trade_Closed := true
        Trade_Result := -1
        Trade_Close_Time := Live_Clock_OK ? timenow : time
        Trade_Close_Exposure_Time := Bar_Reference_Time
    else if TP_hit
        label.new(x=bar_index, y=TP_active, yloc=yloc.price, text="✅", textcolor=color.green, color=na, style=label.style_none, size=size.large)
        Trade_Closed := true
        Trade_Result := 1
        Trade_Close_Time := Live_Clock_OK ? timenow : time
        Trade_Close_Exposure_Time := Bar_Reference_Time
 
// ============================================================================
// ACTIVE TRADE BAR
// ============================================================================
 
bool Trade_Active_Bar = time >= time_i and Trade_Entered and not Trade_Closed
 
// ============================================================================
// PLOTS
// ============================================================================
 
E = plot(time >= time_i ? Entry_p : na, color=color.blue, style=plot.style_circles)
X = plot(time >= time_i ? Exit_p : na, color=color.red, style=plot.style_circles)
T = plot(time >= time_i ? TP_active : na, color=#5eff52, style=plot.style_circles, show_last=100)
C = plot(time >= time_i ? close : na, color=na, display=display.none)
 
// ============================================================================
// DYNAMIC ENTRY <-> CLOSE FILL
// ============================================================================
 
bool long_loss_area = Selected_SIDE == "Long" and Trade_Active_Bar and close < Entry_p
bool long_profit_area = Selected_SIDE == "Long" and Trade_Active_Bar and close > Entry_p
bool short_loss_area = Selected_SIDE == "Short" and Trade_Active_Bar and close > Entry_p
bool short_profit_area = Selected_SIDE == "Short" and Trade_Active_Bar and close < Entry_p
 
color Position_Fill = long_loss_area or short_loss_area ? color.new(color.red, 75) : long_profit_area or short_profit_area ? color.new(color.green, 75) : na
 
fill(E, C, color=Position_Fill)
 
// ============================================================================
// IN PROFIT % ENGINE
// ============================================================================
 
var float Sum_Green = 0.0
var float Sum_Red = 0.0
 
if Trade_Active_Bar
    float Distance_from_Entry = math.abs(close - Entry_p)
    bool Bar_In_Profit = Selected_SIDE == "Long" ? close > Entry_p : close < Entry_p
    bool Bar_In_Loss = Selected_SIDE == "Long" ? close < Entry_p : close > Entry_p
 
    if Bar_In_Profit
        Sum_Green += Distance_from_Entry
    else if Bar_In_Loss
        Sum_Red += Distance_from_Entry
 
float Sum_Total = Sum_Green + Sum_Red
float In_Profit_Perc = Sum_Total > 0 ? Sum_Green / Sum_Total * 100 : na
 
// ============================================================================
// ENTRY / SL / TP PRICE LABELS
// ============================================================================
 
LBL_entry = label.new(x=bar_index + 5, y=Entry_p, yloc=yloc.price, text="En: " + str.tostring(math.round(Entry_p, 5)) + " $", textcolor=#000000, color=color.white, style=label.style_label_left, size=size.small, textalign=text.align_center, text_font_family=font.family_default, text_formatting=text.format_bold)
label.delete(LBL_entry[1])
 
LBL_exit = label.new(x=bar_index + 5, y=Exit_p, yloc=yloc.price, text="Ex: " + str.tostring(math.round(Exit_p, 5)) + " $", textcolor=#000000, color=color.white, style=label.style_label_left, size=size.small, textalign=text.align_center, text_font_family=font.family_default, text_formatting=text.format_bold)
label.delete(LBL_exit[1])
 
LBL_TP = label.new(x=bar_index + 5, y=TP_active, yloc=yloc.price, text="TP: " + str.tostring(math.round(TP_active, 5)) + " $", textcolor=#0e110e, color=#d3f6da, style=label.style_label_left, size=size.small, textalign=text.align_center, text_font_family=font.family_default, text_formatting=text.format_bold)
label.delete(LBL_TP[1])
 
// ============================================================================
// TIME ANALYTICS
// ============================================================================
 
int Elapsed_End_Time = Trade_Closed ? Trade_Close_Exposure_Time : Trade_Entered ? Bar_Reference_Time : na
int Elapsed_ms = Trade_Entered and not na(Entry_Count_Start) and not na(Elapsed_End_Time) ? math.max(Elapsed_End_Time - Entry_Count_Start, 0) : 0
 
Entry_Date_txt = Trade_Entered ? f_datetime(Trade_Entry_Time) : "pending..."
Elapsed_Time_txt = Trade_Entered ? f_elapsed(Elapsed_ms) : "pending..."
 
// PRE-ENTRY  -> pending...
// ACTIVE     -> in progress...
// CLOSED     -> actual closing date
End_Date_txt = Trade_Closed ? f_datetime(Trade_Close_Time) : Trade_Entered ? "in progress..." : "pending..."
 
End_Header_txt = Trade_Result == 1 ? "✅ End Date" : Trade_Result == -1 ? "❌ End Date" : Trade_Entered ? "🟡 End Date" : "End Date"
 
End_BG = Trade_Result == 1 ? #dcffdd : Trade_Result == -1 ? #ffdcdc : Trade_Entered ? color.new(color.yellow, 85) : color.new(color.white, 0)
 
End_Text_Color = Trade_Result == 1 ? #17861b : Trade_Result == -1 ? #ff0000 : #000000
 
// ============================================================================
// POSITION SIZING
// ============================================================================
 
var float Coin_Size_Theory = 0
var float Coin_Size = 0
var float Value_dollars = 0
var float SL_Cost_Loss = 0
var float Paied_Fees_D = 0
var float RR_Calc = 0
 
if Selected_SIDE == "Long"
    Coin_Size_Theory := Risk_perc * Balance / (Entry_p * (1 + f_ASS) - Exit_p * (1 - f_ASS))
    Coin_Size := Coin_Size_Theory > 0 and CONT_Tolerance > 0 ? math.floor(Coin_Size_Theory / CONT_Tolerance) * CONT_Tolerance : na
    Value_dollars := Coin_Size * Entry_p
    SL_Cost_Loss := Value_dollars * (Exit_p / Entry_p - 1)
    Paied_Fees_D := -Coin_Size * (Entry_p * f_ASS + Exit_p * f_ASS)
    RR_Calc := (TP_active - Entry_p) / (Entry_p - Exit_p)
 
else if Selected_SIDE == "Short"
    Coin_Size_Theory := Risk_perc * Balance / (Entry_p * (f_ASS - 1) + Exit_p * (f_ASS + 1))
    Coin_Size := Coin_Size_Theory > 0 and CONT_Tolerance > 0 ? math.floor(Coin_Size_Theory / CONT_Tolerance) * CONT_Tolerance : na
    Value_dollars := Coin_Size * Entry_p
    SL_Cost_Loss := Value_dollars * (1 - Exit_p / Entry_p)
    Paied_Fees_D := -Coin_Size * (Entry_p * f_ASS + Exit_p * f_ASS)
    RR_Calc := (Entry_p - TP_active) / (Exit_p - Entry_p)
 
// ============================================================================
// SIZE DISPLAY
// ============================================================================
 
Coin_Size_Theory_txt = Coin_Size_Theory > 0 ? str.tostring(Coin_Size_Theory, "#.########") + "\n" + syminfo.ticker : "n/a"
Coin_Size_txt = not na(Coin_Size) ? str.tostring(Coin_Size, "#.########") + "\n" + syminfo.ticker : "n/a"
 
// ============================================================================
// PNL
// ============================================================================
 
Net_PNL_on_TP = Selected_SIDE == "Long" ? Value_dollars * (TP_active / Entry_p - 1) : Value_dollars * (1 - TP_active / Entry_p)
 
Live_NetPNL_Open = Selected_SIDE == "Long" ? Value_dollars * (close / Entry_p - 1) + Paied_Fees_D : Selected_SIDE == "Short" ? Value_dollars * (1 - close / Entry_p) : na
 
// No PNL exists before the planned Entry has actually been reached.
// Once closed, PNL is frozen at the modeled TP/SL result.
Live_NetPNL = not Trade_Entered ? na : Trade_Closed ? Trade_Result == 1 ? Net_PNL_on_TP : Trade_Result == -1 ? SL_Cost_Loss : na : Live_NetPNL_Open
 
Live_PNL_Header = Trade_Result == 1 ? "✅ Live PNL [$]" : Trade_Result == -1 ? "❌ Live PNL [$]" : "Live PNL [$]"
 
Live_PNL_txt = not Trade_Entered or na(Live_NetPNL) ? "n/a" : str.tostring(math.round(Live_NetPNL, 2)) + " $"
 
// ============================================================================
// PALETTE
// ============================================================================
 
Positive_Text_Color = #17861b
Negative_Text_Color = #ff0000
 
Positive_BG_Color = #dcffdd
Negative_BG_Color = #ffdcdc
 
text_PNL_color = not Trade_Entered or na(Live_NetPNL) ? #000000 : Live_NetPNL > 0 ? Positive_Text_Color : Live_NetPNL < 0 ? Negative_Text_Color : #000000
 
BG_text_PNL_color = not Trade_Entered or na(Live_NetPNL) ? color.new(color.white, 0) : Live_NetPNL > 0 ? Positive_BG_Color : Live_NetPNL < 0 ? Negative_BG_Color : color.new(color.white, 0)
 
RR_Text_Color = RR_Calc >= 0 ? Positive_Text_Color : Negative_Text_Color
Coin_Size_Text_Color = na(Coin_Size) ? #000000 : Coin_Size >= 0 ? Positive_Text_Color : Negative_Text_Color
TP_PNL_Text_Color = Net_PNL_on_TP >= 0 ? Positive_Text_Color : Negative_Text_Color
 
Side_BG_Color = Trade_Result == 1 ? Positive_BG_Color : Selected_SIDE == "Long" ? color.new(color.green, 90) : color.new(color.red, 90)
 
TP_PNL_BG_Color = Trade_Result == 1 ? Positive_BG_Color : color.new(color.white, 0)
 
CLR = Value_dollars / Balance
 
// ============================================================================
// IN PROFIT % TABLE ANALYTICS
// ============================================================================
 
In_Profit_txt = na(In_Profit_Perc) ? "n/a" : str.tostring(math.round(In_Profit_Perc, 2)) + "%"
In_Profit_Text_Color = na(In_Profit_Perc) ? #000000 : In_Profit_Perc >= 50 ? Positive_Text_Color : Negative_Text_Color
 
// ============================================================================
// TABLE SIZE
// ============================================================================
 
width = input.float(defval=1, step=0.05, title="Mult. WIDTH:", inline="1", group="Table Size")
height = input.float(defval=0.8, step=0.05, title="Mult. HEIGTH:", inline="1", group="Table Size")
 
// 16 rows:
// 0 header
// 1-6 position/trade information
// 7 theoretical size
// 8 executable rounded-down size
// 9-15 remaining analytics
var tbl_0 = table.new(position.middle_right, 2, 16, frame_color=#000000, frame_width=1, border_width=1, border_color=color.new(color.white, 100))
 
// ============================================================================
// POSITION TABLE
// ============================================================================
 
if P_Sizer_Button and time >= time_i
 
    table.cell(tbl_0, 0, 0, text="Position Details", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.black, 30), text_color=color.white, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 0, text="Sizing ", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.black, 30), text_color=color.white, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 1, text="Entry Date", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 1, text=Entry_Date_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 2, text="Elapsed Time*", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 2, text=Elapsed_Time_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 3, text=End_Header_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 3, text=End_Date_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=End_BG, text_color=End_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 4, text="Side ", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 5, text="[%] E-SL Dist.", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 6, text="Trade RR Ratio", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    // Raw mathematical size before applying CONT-Tolerance.
    table.cell(tbl_0, 0, 7, text="Theor. Size [COIN]", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.yellow, 90), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 7, text=Coin_Size_Theory_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    // Actual executable size after floor rounding.
    table.cell(tbl_0, 0, 8, text="Size [COIN]", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.yellow, 90), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 9, text="Size Value$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.yellow, 90), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 10, text="Cross Lev. Ratio", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.yellow, 90), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 11, text="In Profit [%]", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.yellow, 90), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 11, text=In_Profit_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=In_Profit_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 12, text="Fees [$] Cost", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 13, text="SL [$] Loss", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 14, text="PNL on TP: ", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 14, text=str.tostring(math.round(Net_PNL_on_TP, 2)) + "$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=TP_PNL_BG_Color, text_color=TP_PNL_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
    table.cell(tbl_0, 0, 15, text=Live_PNL_Header, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=#cce2f0e5, text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
    table.cell(tbl_0, 1, 15, text=Live_PNL_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=BG_text_PNL_color, text_color=text_PNL_color, text_size=size.normal, text_formatting=text.format_bold)
 
    if Selected_SIDE == "Long"
 
        table.cell(tbl_0, 1, 4, text=Selected_SIDE + " 🟢", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=Side_BG_Color, text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 5, text=str.tostring(math.round((Exit_p / Entry_p - 1) * 100, 2)) + "%", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 6, text=str.tostring(math.round(RR_Calc, 3)) + " R", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=RR_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 8, text=Coin_Size_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=Coin_Size_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 9, text=str.tostring(math.round(Value_dollars, 2)) + "$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 10, text=str.tostring(math.round(CLR, 2)) + "x", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 12, text=str.tostring(math.round(Paied_Fees_D, 2)) + "$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=Negative_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 13, text=str.tostring(math.round(SL_Cost_Loss, 2)) + "$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=Negative_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
    else if Selected_SIDE == "Short"
 
        table.cell(tbl_0, 1, 4, text=Selected_SIDE + " 🔴", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=Side_BG_Color, text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 5, text="+" + str.tostring(math.round((Exit_p / Entry_p - 1) * 100, 2)) + "%", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 6, text=str.tostring(math.round(RR_Calc, 2)) + " R", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=RR_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 8, text=Coin_Size_txt, width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=Coin_Size_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 9, text=str.tostring(math.round(Value_dollars, 2)) + "$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 10, text=str.tostring(math.round(CLR, 2)) + "x", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=#000000, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 12, text=str.tostring(math.round(Paied_Fees_D, 2)) + "$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=Negative_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
        table.cell(tbl_0, 1, 13, text=str.tostring(math.round(SL_Cost_Loss, 2)) + "$", width=11 * width, height=5 * height, text_halign=text.align_center, bgcolor=color.new(color.white, 0), text_color=Negative_Text_Color, text_size=size.normal, text_formatting=text.format_bold)
 
var tbl_x = table.new(position.bottom_left, 1, 1, frame_color=#000000, frame_width=1, border_width=1, border_color=color.new(color.white, 100))

← 返回列表