TradingView
RedKTrader
2021年3月28日晚上9點30分

RedK_Portfolio Tracker v2: few enhancements and display options 

Apple Inc.NASDAQ

描述

This is an update for the PTracker v1 that I published couple of days ago. wanted to publish this as a separate script to get a chance to show how the new Portfolio Summary Infobox can be displayed on the price chart as an option. In my opinion, that info box is the most important element in this tool and that's the piece i was most looking for.

quick note here: you can track your portfolio (if not so many positions) by entering something like [MSFT * 1000 + AAPL * 1000 + INTC * 2000 ] (without the brackets) in TradingView's chart symbol area - TradingView will resolve these symbols and chart the total -- there's a nice post by our friend @boji1 about this in a lot more details - however, that wouldn't show the stats that i need to look at to track my portfolio on daily basis.

i also made couple of other enhancements, like adding the ability to include "free cash" in the portfolio - While this free cash value will impact the Total P/L and P/L %, as part of the overall portfolio (and the denominator), it will not impact the "cost of positions" or the (current) "value of positions" -- also "Cash" will not count towards the total 10 positions that we can track with this tool.

Using Portfolio Tracker as a floating panel on the price chart
====================================================
  • By default, when the Portfolio Tracker is added to the chart, it will occupy its own lower panel like the picture above.
  • if your charts are already busy (like mine :)) - you most probably already have a couple of lower studies and it's crowded there.
  • in this case, you can use the Object Tree tool after adding the PTracker, to drag it onto the price panel, or you can also do that by right-clicking on the infobox and choose to move up to the price panel.
  • when you do that, remember to also use the Style settings of PTracker to hide both Portfolio and PnL plots, and choose Scale = no scale - this way you get the infobox to work like a floating panel on the price chart



here's a screenshot that shows this scenario - also shows how the infobox color can be easily changed from the PTracker settings to suit your chart background and for best visibility


i hope this is useful in your trading - i look forward to @TradingView team surprising us with a real portfolio tracking capability soon :)

good luck.
評論
PineCoders
RedKTrader
@PineCoders, thank you ..
fibonacci69
perfect ,very good.
but only the long position can be followed.
short positions ?
RedKTrader
@fibonacci69, there should be no issues adding short stock positions. qty needs to be negative, and proceeds of the short need to be added to the cash.

i need to review the current bar PnL and PnL% though - i don't like how they looked in that scenario .. good thought for the next update.

thanks for the question. :)
fibonacci69
@RedKTrader, Thanks a lot sir... Also,can the date of cost be added to positions? To show for informational purposes only.
Chase37
This is great! Thank You!
Tradeanalyst
Thanks a lot
jan_chrapek
This is a great project although its main limitation is that it can track only 10 positions. In the linked article you've also shown the method with "portfolio string", but TradingView also allows sums of only 10 elements. Of course, the script could be easily modified to support more positions (unless TradingView also doesn't allow it), but still entering all the details to separate text boxes would take much time. Instead, the optimal solution would be parsing similar "portfolio string" which could be exported from Excel. Could you make a version of the script which works as I described or show how to do it?
sherifhemida
Thanks for for sharing this. I am trying to include few Canadian tickers with my US tickers, problem is I am getting few percent extra in the Value of positions. Cost of positions seems fine, any hint what might I had missed?, example edited lines:
cadrate = 1.2579009
cost_2 = input(title = "Cost", type = input.float, defval = 9.260, inline = "#2")/cadrate
val_2 = p_2 ? security(sym_2, timeframe.period, close, barmerge.gaps_off) : 0 / cadrate

I also had few more positions so total is 14 now, not sure If that is causing issues, edited lines:
TotalValue = tvalue_1 + tvalue_2 + tvalue_3 + tvalue_4 + tvalue_5 + tvalue_6 + tvalue_7 + tvalue_8 + tvalue_9 + tvalue_10+ tvalue_11+ tvalue_12+ tvalue_13+ tvalue_14
TotalCost = tcost_1 + tcost_2 + tcost_3 + tcost_4 + tcost_5 + tcost_6 + tcost_7 + tcost_8 + tcost_9 + tcost_10 + tcost_11 + tcost_12 + tcost_13 + tcost_14
numpos = (p_1? 1 : 0) + (p_2? 1 : 0) + (p_3? 1 : 0) + (p_4? 1 : 0) + (p_5? 1 : 0) + (p_6? 1 : 0 ) + (p_7? 1 : 0) + (p_8? 1 : 0) + (p_9? 1 : 0) + (p_10? 1 : 0)+ (p_11? 1 : 0)+ (p_12? 1 : 0)+ (p_13? 1 : 0)+ (p_14? 1 : 0)
RedKTrader
@sherifhemida, it will be hard to troubleshoot issues this way without a deeper look at your modifications
- but please note that this script does not handle currency conversion - all your entries (and outputs) will be expected to be in the same currency - and should be in USD. hope this helps
更多