Portfolio Functions In ThinkOrSwim

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
Having trouble using portfolio functions on your chart?
Here are the limitations of portfolio functions:
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio
WByOa8y.png

See the below thread for a myriad of ways that members use portfolio functions:
https://usethinkscript.com/threads/...labels-of-owned-equities-in-thinkorswim.7089/
 
Last edited:

Thane313

New member
I'd like to know this too, and also stock buying power for margin accounts. I can't seem to dig anything up.
 

METAL

Member
Having trouble using portfolio functions on your chart?
Here are the limitations of portfolio functions:
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio

See the below thread for a myriad of ways that members use portfolio functions:
https://usethinkscript.com/threads/...labels-of-owned-equities-in-thinkorswim.7089/
@MerryDay Do you know if total cash represents "Available Funds for Trade"? I cannot locate a key or definition for these. Thank You for the reply by the way.
 
Last edited by a moderator:

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
@MerryDay Do you know if total cash represents "Available Funds for Trade"? I cannot locate a key or definition for these. Thank You for the reply by the way.
"Available Funds for Trade" == The amount of money available to purchase securities in your brokerage account. It includes your money market settlement fund balance, pending credits or debits, and margin cash available (if approved for margin).

"GetTotalCash" is ONLY the actual cash liquidity in the account.

In the example below the GetTotalCash == $4,161.34 The "Stock Buying Power" of $8,322.68 is not a data point that the ToS platform provides access to in our ThinkScripts.
nzfwJZ1.png


https://tlc.thinkorswim.com/center/...alCash#:~:text=total amount of cash available
hdWHkwP.png
 

METAL

Member
# Simple Position Calculator
# Assembled by BenTen at UseThinkScript.com

def current_price = close;
def limit = GetTotalCash () / current_price;
AddLabel(yes, Concat("Shares Ava =", Round(limit)), color.orange);

I tried this. Got it to work but it is pulling from the wrong value. I guess TOS doesn't allow for me to point to Option buying Power or Available Funds for Trading (After getting advanced enabled the Available Funds for Trading is disabled) I can only use the Option Buying Power for the amount of funds I may trade.
 
Last edited by a moderator:

mluttph

New member
On a sell, in a 1st trgs seq, its easy sell 100%. But on a buy I don't know what the account buying amount will be when it is triggered. So for now I use an amount that I think should be available. I'm using studies to trigger these trades. Is there a way to get it to buy the full available amount in the account? Thanks for any help.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
In a cash account. GetNetLiq/GetTotalCash aren't quite what I was looking for and couldn't find anything that would show 'Available Funds For Trading'. Thanks in advance.
I'd like to know this too, and also stock buying power for margin accounts. I can't seem to dig anything up.
On a sell, in a 1st trgs seq, its easy sell 100%. But on a buy I don't know what the account buying amount will be when it is triggered. So for now I use an amount that I think should be available. I'm using studies to trigger these trades. Is there a way to get it to buy the full available amount in the account? Thanks for any help.
Read through this thread to understand what choices are available on the ToS platform:
https://usethinkscript.com/threads/portfolio-functions-in-thinkorswim.11485/
 

mluttph

New member
What would happen if you used the "100%" option for "Buy"?
Would it be different for a margin account?

I'm using a 1st trgs seq conditional order. Sell 100% then buy 100%, wondering what would happen.
So far I have been using 100% for the sale and a dollar amount for the buy. But its not ideal.
I'm using studies for the trigger but not using "GetTotalCash", not sure how to. I may need to work on that.

I think you are saying it should work as long as "Use extended hours" is checked.
 
Last edited by a moderator:

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
What would happen if you used the "100%" option for "Buy"?
Would it be different for a margin account?

I'm using a 1st trgs seq conditional order. Sell 100% then buy 100%, wondering what would happen.
So far I have been using 100% for the sale and a dollar amount for the buy. But its not ideal.
I'm using studies for the trigger but not using "GetTotalCash", not sure how to. I may need to work on that.

I think you are saying it should work as long as "Use extended hours" is checked.
To use "GetTotalCash"
Ruby:
# Simple Position Calculator
# Assembled by BenTen at UseThinkScript.com

def current_price = close;
def limit = GetTotalCash () / current_price;
AddLabel(yes, Concat("Shares Ava =", Round(limit)), color.orange);

The trade would use 100% of the actual cash liquidity in the account.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio/GetTotalCash#:~:text=total amount of cash available
hdWHkwP.png


  • TDA does not provide the information required to calculate the balance of your margin account.
  • the documentation seems to state that extended hours must be turned on
 

mluttph

New member
To use "GetTotalCash"
Ruby:
# Simple Position Calculator
# Assembled by BenTen at UseThinkScript.com

def current_price = close;
def limit = GetTotalCash () / current_price;
AddLabel(yes, Concat("Shares Ava =", Round(limit)), color.orange);

The trade would use 100% of the actual cash liquidity in the account.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio/GetTotalCash#:~:text=total amount of cash available
hdWHkwP.png


  • TDA does not provide the information required to calculate the balance of your margin account.
  • the documentation seems to state that extended hours must be turned on
I don't understand how that gets into my conditional order.
 

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