Using Portfolio Functions in ThinkorSwim

Rose Investing

Rose Investing

New member
Hello, I've been trying to use my the portfolio functions available to me such as "GetAveragePrice()" or "GetOpenPL()", however all of them seem to be giving me the value N/A regardless of me being in a position or not. I checked the instructions in the learning center and my chart has the "last" price type and I was using the 1min aggregation type which is acceptable. I don't have much money in my account so I just bought one share of JDST and one share of AAL around 1 pm (I'm not sure if the time matters just want to be descriptive). Both times when I bought the account my label showed nothing. Here is the script for my label:

#Script
addLabel(yes, getAveragePrice());
# end of script
it's just that one line but all I see in my lable is N/A. Has anyone had any issues like this using portfolio actions or does anyone know what might be the problem here? Let me know if you need me to elaborate on any of the points I've made
 
P

Pensar

Active member
VIP
@Rose Investing, I dont know much about portfolio functions in thinkscript, its something I need to learn. However, perhaps this code can help you. I found it in the thinkScript Community OneNote.

Code:
# All the Portfolio Functions in a Label
# Mobius

def GetAveragePrice = GetAveragePrice();
def GetNetLiq = GetNetLiq();
def GetOpenPL = GetOpenPL();
def GetQuantity = GetQuantity();
def GetTotalCash = GetTotalCash();

addLabel(1, "GetAveragePrice = " + GetAveragePrice +
          "  GetNetLiq = " + GetNetLiq +
          "  GetOpenPL = " + GetOpenPl +
          "  GetQuantity = " + GetQuantity +
          "  GetTotalCash = " + GetTotalCash, color.white);
 
T

Tweak155

New member
I also have this problem. It works properly in paper trading, but I only get N/A in real trading. Anyone know why that might be?
 
chex

chex

New member
I had the same problem, getAveragePrice was always "N/A". I contacted support via live chat and they immediately pointed me to the "Advanced Features" setting which needs to be enabled: Ameritrade.com > Client Services > My Profile > General > Advanced Features
It took a few hours to kick in, but now I get the correct values from the Portfolio functions. (y)
 
T

Tweak155

New member
I had the same problem, getAveragePrice was always "N/A". I contacted support via live chat and they immediately pointed me to the "Advanced Features" setting which needs to be enabled: Ameritrade.com > Client Services > My Profile > General > Advanced Features
It took a few hours to kick in, but now I get the correct values from the Portfolio functions. (y)
Ha! I also figured this out a couple days ago (I think I turned it on the day I posted my reply), but forgot to update this chain. It also fixes "Show Trades" and my mobile alerts. Been a life saver. Google should have this answer more readily!

Thanks!
 

Similar threads

Top