# Portfolio Return Analysis for ThinkorSwim

##### 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

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

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

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?