OPEN-SOURCE SCRIPT
Telah dikemas kini

Portfolio P&L Table 10 Slots

50
Overview

This indicator displays a compact, Excel-style position P&L table directly on your TradingView chart. It is designed to help traders track unrealized profit/loss for a manually-entered position and ensure the calculations only apply to the symbols you actually trade, preventing confusion when switching between tickers.

The script is symbol-aware: it checks the current chart symbol against up to 10 user-defined position slots and shows P&L only when a match is found.

Core Concept

Most P&L scripts on TradingView rely on a single set of inputs (average price, quantity), which remains active even when the user changes chart symbols. That can lead to incorrect P&L displays on instruments where no position exists.

This indicator solves that by combining:

Symbol matching logic (ticker / exchange:ticker / base ticker normalization)

Slot-based position storage (up to 10 positions)

Dynamic real-time P&L calculations driven by the chart’s live price

As a result, the table behaves like a “position panel” that follows the chart, while respecting your actual holdings list.

Matching & Display Logic
Symbol Detection

The indicator compares the current chart symbol to each slot’s symbol using multiple matching methods to reduce false mismatches:

Full symbol (EXCHANGE:TICKER)

Ticker only (TICKER)

Normalized “base ticker” extraction (useful when your chart format differs from inputs)

Position Selection

The first matching slot is selected and displayed.

If no slot matches, the table shows “No position for this symbol” and does not output P&L values.

P&L Calculation Logic

When a valid slot is matched and its values are valid:

Unrealized Gross P&L

Long: (Last Price − Avg Price) × Quantity

Short: (Avg Price − Last Price) × Quantity (handled via direction multiplier)

Unrealized Net P&L (optional)

If fees are enabled, the script subtracts the slot’s total fees from gross P&L.

P&L %

Calculated relative to average price, direction-adjusted for long/short positions.

Breakeven Price

Without fees: breakeven = average price

With fees: breakeven is adjusted using fees / quantity and direction.

The table updates automatically with market movement because all values are recalculated from the chart’s current price.

Inputs and Defaults
General

Include Fees? (default: Off)

Text Size

Table Position (Top/Bottom, Left/Right)

Slots (1 → 10)

Each slot contains:

Symbol (example formats: NVTS, NASDAQ:NVTS, NYSE:PATH)

Side (Long / Short)

Average Price

Quantity

Total Fees (optional; applied only when “Include Fees” is enabled)

Colors (Fully Customizable)

The table supports user-defined colors for:

Header text/background

Body text/background

Positive P&L color

Negative P&L color

Neutral/no-position color

This allows you to match the table visually to any chart theme.

The indicator is intended for:

Quick P&L visibility while charting

Avoiding accidental P&L “carry over” when switching symbols

Tracking a shortlist of positions without external spreadsheets

If you trade more than 10 tickers regularly, the script can be extended further using the same slot architecture.

Limitations

Values are unrealized and based on the chart’s price (close/last available feed).

The script does not track multiple lots per symbol automatically; each slot represents a single consolidated position (avg + total qty).

Disclaimer

This script is provided for educational and analytical purposes only. It does not constitute financial advice, investment recommendations, or an invitation to trade. Trading involves risk, and past performance does not guarantee future results. Always verify your position data and calculations independently before making trading decisions.
Nota Keluaran
Overview

This indicator displays a compact, Excel-style position P&L table directly on your TradingView chart. It is designed to help traders track unrealized profit/loss for a manually-entered position and ensure the calculations only apply to the symbols you actually trade, preventing confusion when switching between tickers.

The script is symbol-aware: it checks the current chart symbol against up to 10 user-defined position slots and shows P&L only when a match is found.

Core Concept

Most P&L scripts on TradingView rely on a single set of inputs (average price, quantity), which remains active even when the user changes chart symbols. That can lead to incorrect P&L displays on instruments where no position exists.

This indicator solves that by combining:

Symbol matching logic (ticker / exchange:ticker / base ticker normalization)

Slot-based position storage (up to 10 positions)

Dynamic real-time P&L calculations driven by the chart’s live price

As a result, the table behaves like a “position panel” that follows the chart, while respecting your actual holdings list.

Matching & Display Logic
Symbol Detection

The indicator compares the current chart symbol to each slot’s symbol using multiple matching methods to reduce false mismatches:

Full symbol (EXCHANGE:TICKER)

Ticker only (TICKER)

Normalized “base ticker” extraction (useful when your chart format differs from inputs)

Position Selection

The first matching slot is selected and displayed.

If no slot matches, the table shows “No position for this symbol” and does not output P&L values.

P&L Calculation Logic

When a valid slot is matched and its values are valid:

Unrealized Gross P&L

Long: (Last Price − Avg Price) × Quantity

Short: (Avg Price − Last Price) × Quantity (handled via direction multiplier)

Unrealized Net P&L (optional)

If fees are enabled, the script subtracts the slot’s total fees from gross P&L.

P&L %

Calculated relative to average price, direction-adjusted for long/short positions.

Breakeven Price

Without fees: breakeven = average price

With fees: breakeven is adjusted using fees / quantity and direction.

The table updates automatically with market movement because all values are recalculated from the chart’s current price.

Inputs and Defaults
General

Include Fees? (default: Off)

Text Size

Table Position (Top/Bottom, Left/Right)

Slots (1 → 10)

Each slot contains:

Symbol (example formats: NVTS, NASDAQ:NVTS, NYSE:PATH)

Side (Long / Short)

Average Price

Quantity

Total Fees (optional; applied only when “Include Fees” is enabled)

Colors (Fully Customizable)

The table supports user-defined colors for:

Header text/background

Body text/background

Positive P&L color

Negative P&L color

Neutral/no-position color

This allows you to match the table visually to any chart theme.

The indicator is intended for:

Quick P&L visibility while charting

Avoiding accidental P&L “carry over” when switching symbols

Tracking a shortlist of positions without external spreadsheets

If you trade more than 10 tickers regularly, the script can be extended further using the same slot architecture.

Limitations

Values are unrealized and based on the chart’s price (close/last available feed).

The script does not track multiple lots per symbol automatically; each slot represents a single consolidated position (avg + total qty).

Disclaimer

This script is provided for educational and analytical purposes only. It does not constitute financial advice, investment recommendations, or an invitation to trade. Trading involves risk, and past performance does not guarantee future results. Always verify your position data and calculations independently before making trading decisions.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.