Editors' picksOPEN-SOURCE SCRIPT

RedK Portfolio Tracker [Table Version]

Updated
RedK Portfolio Tracker is a simple tool that enables a trader to monitor and track a portfolio of up to 10 holdings (+ free cash) in real time - directly on the chart

Now that we have tables in Pine, this is a table version of my previously published Portfolio Tracker

- The table works better in visualizing the various table elements (title row, column labels..etc), and is more flexible in allowing color coding of gain/loss. for many traders, myself included, these simple visual signals are valuable in helping timely trading decisions.

I'll come back and improve this script as i'm really enjoying the ability to track things this way - if you liked this and want to receive the updates, please flag / favorite it below and you'll get notified when i publish new versions.

Some new features for the table version:
- ability to change default color of various table elements (text, default background, title background, gain/loss color, border..etc)
- ability to change the text size to suit your monitor and visual preference
- ability to change table position

The "portfolio-specific" inputs are similar to the previous version - we get the ability to enter up to 10 positions, entry price and qty, then also add the free cash

- also a change from prior version, this table will plot by default on the price chart, but will have no scale - the portfolio ploy itself will also show (blue/orange stepping line) but the PnL plot will be hidden by default -- how we plot the portfolio & P/L is possibly one of the areas for improvements for next versions - also thinking of other adding valuable data i track in my own trading, like the quarterly dividends for the held positions .. we'll see - this is just a start

hope some will find this useful. feel free to comment.
Release Notes
- Brought back the "Value of Positions" and added the "Return on Positions" rows
- Proper distinction between Total P/L % (includes the free cash in the calculation) vs the "Return on Positions" which only looks at cost of positions vs "current value" - please note some brokers may have slightly different ways of calculating/naming these values - I'm sticking to how i see most brokers do this.

- sorry for showing negative values - just want to validate/show the dynamic color change for +ve vs -ve values ;)
Release Notes
v3 adds few changes mainly to enable tracking of short positions when needed
- separate "Return on Positions" from PnL - wanted to see these values separately to validate calculations were done properly if short positions are held
- separate "Portfolio Summary" and "Portfolio Performance" in different sections. Added the "Initial Capital" line
- maybe later we can separate short and long positions each in their own columns to avoid the confusing P/L math :)
- Please note, when we short, we should include the cash proceeds of the short position in the "Cash" entry in the settings.

the example below shows an example of a portfolio with one short position (sold 1,000 NKLA @ $20) - and how that would reflect on the Portfolio Table.

snapshot
Release Notes
V4 adds summary of quarterly dividends for the positions in the portfolio - Been eager to do this for sometime :)
- note that the qtrly dividend yield is relative to initial capital

- also all plots are now hidden by default, except the portfolio table itself
- few other clean-ups
- Sample chart above shows how the table colors can be changed to suit user preference - you don't have to use mine :)
Release Notes
v5 Introduces a new dynamic "Target Tracker" section - and cleans up the table a little further:
- The Portfolio Tracker will only show when a target is set in the indicator settings (check box), and target needs to be > zero
- When a target is set, we really want to track against the 100% value, so i kept separate rows for PnL as "percent of target", and the PnL "variance to target" (VTT) - which shows the gap from our current PnL value above of below the 100% target value. Traders will differ in how they track their PnL against a target so both values are available.
- removed redundant PnL row

couple of other trading metrics i track are related to PnL Run Rates (yearly, monthly, weekly) -- not sure if others are interested in bringing these too - but they will require some date entry and manipulation .. so i'm not really sure. let me know.
Release Notes
v5.1
- fixed a bug where the dividend table breaks for instruments with no dividends data (thanks to remcoros for feedback)
- added an option to the settings to show / hide the dividends section.
- in consistency with the target section, for the dividends section to appear, the option to show the dividends section should be enabled *AND* quarterly dividends amount for the current portfolio should be > $0
Release Notes
v6.0 Changes:
- Upgraded to Pine v5
- Supports crypto positions: changed the way dividends are calculated to avoid issues with crypto positions (thanks for the feedback on this) - big thanks to our Pine Wizards for their many advices.
- Some code clean-ups
Release Notes
v7.0 changes:
- code optimization & streamlining, some variables do not need to calculate on each bar. Table should load slightly faster
- default position of table changed to lower right - makes it easier to identify this version vs prior ones.
PNLportfolioPortfolio managementpositionmanagementredktableTrend Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer