Portfolio Return Analysis for ThinkorSwim

justAnotherTrader

Member
VIP
VIP Enthusiast
Alright so first off I love this site. It has inspired me to try new things and see how the community decides to participate to validate or invalidate ideas. This idea is I believe novel, so if I am incorrect please let me know to save me the headache of trying to create the wheel so to speak. I have been trading a long time with a background in finance and mathematics so I have always wanted to marry both technical and fundamental analysis. This indicator is hopefully going to be one of many where I try to combine both.

The nuts and bolts of this are pretty straight forward. In this example you add 5 stocks that are in your hypothetical portfolio and their corresponding weights to give a cumulative return on that portfolio. Going forward I plan on measuring the standard deviation of returns in order to find which "portfolios" give the best risk/reward ratios. The possibilities in my opinion are endless. Maybe we use an rsi indicator to measure returns or i dont know im just brain storming but please let me know how the community feels about these ideas.

The bottom indicator shows the cummulative returns for the 5 chosen stocks
iSQ8VyA.png


Code:
# Portfolio Return Analysis
#
# This is the first of several risk to return portfolio analysis indicators I am working on.
# 
# 2020-02-29
#

input t1 = "EBAY";
input t2 = "WMT"; 
input t3 = "AMZN";
input t4 = "COST";
input t5 = "BABA";


input w1 = .2; #hint Weight of Stock 1
input w2 = .2; #hint Weight of Stock 2
input w3 = .2; #hint Weight of Stock 3
input w4 = .2; #hint Weight of Stock 4
input w5 = .2; #hint Weight of Stock 5

def t1_return = close(t1)/close(t1)[1]-1;
def t2_return = close(t2)/close(t2)[1]-1;
def t3_return = close(t3)/close(t3)[1]-1;
def t4_return = close(t4)/close(t4)[1]-1;
def t5_return = close(t5)/close(t5)[1]-1;

plot portfolioWeightedReturns = TotalSum(t1_return*w1+t2_return*w2+t3_return*w3+t4_return*w4+t5_return*w5);
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
I like this idea. Have you done more than one portfolio? What did you learn from comparing them?
 

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top