Is it possible to monitor P&L on the charts tab in Thinkorswim


0
0

Currently when I am in a trade looking on my charts tab, the only way I know to check the current P&L is to click over to the monitor tab. Is there a way to view the P&L on the charts tab or some alternative that would allow me to see both at the same time? Thanks in advance.

Marked as spam
Posted by (Questions: 2, Answers: 4)
Asked on May 4, 2017 1:00 pm
14139 views
1
Private answer

It is possible to add a chart label to an individual chart. The chart label function is very basic.

You can read more here: http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddLabel.html

This single line of code will display a chart label in the upper left corner of the chart showing the current P/L for the symbol being charted:

AddLabel(yes, GetOpenPL(), Color.WHITE);

The key to this line of code is a function called GetOpenPL(). There are restrictions to what time frames are supported for this function. This function does not work in a custom watchlist column. You can read more details here: http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio.html

If you wanted the chart label to display the P/L of a symbol other than what is being plotted you can do this:

AddLabel(yes, GetOpenPL("AAPL"), Color.WHITE);

You just change the ticker symbol in quotes to something that is in your current account portfolio. In this way you could add multiple chart labels, one for each symbol. And you can update the text of the label to display the ticker symbol assigned to each:

AddLabel(yes, "APPL P/L $" + GetOpenPL("AAPL"), Color.WHITE);
AddLabel(yes, "AMZN P/L $" +GetOpenPL("AMZV"), Color.WHITE);

If you wanted the total combined P/L for all open positions you would need to add lines of code to get the P/L for each symbol, add those values together and display them in a chart label:

def positionOne = GetOpenPL("AAPL");
def positionTwo = GetOpenPL("AMZN");
def totalPL = positionOne + positionTwo;
AddLabel(yes, "Total P/L $" + totalPL, Color.WHITE);

As a homework assignment, I would like to see someone post the code required to show the P/L of an option position. Hint: you would use the OPRA code as the symbol. Let’s see if you can work out how to show the P/L for a complex spread like a calendar or butterfly.

Be sure to up-vote any answers that best solve your question!

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 4, 2017 3:28 pm
0

Is your homework assignment possible? I would be very interested in something like this. What code would allow me to pull all of my open option positions linked to an individual underlying?

( at February 25, 2018 12:21 pm)
0

The homework assignment is possible. I created one for calendars and another for butterflies. They require the manual input of OPRA codes and entry price. As to the second part of your question. There is a built in watchlist for account positions. That is the closest you can get. You can add columns to the watchlist showing current P/L and other metrics related to account positions.

( at February 25, 2018 2:41 pm)
0

Thanks. That is about where I was at. Manual input but no way to pull a position on a derivative. I have contemplated trying GetNextITMOption / GetNextOTMOption to look at all strikes and check for a position. It would not be an ideal solution.

( at February 25, 2018 4:25 pm)
0
That would be a solution far more complex than I am able to provide free of charge in the Q&A forum. I have clients who have paid me to produce solutions far less complex than this. So I must respect them by not giving away items that others have been willing to pay for.
( at April 12, 2020 7:14 pm)
0
I put the following together for a subplot based on TOS PositionOpenPL. It shows P/L of an Iron Condor over the timeframe that is selected for the chart. declare lower; input calculationMode = ProfitLossMode.COST_BASIS; plot PositionOpenPL = GetOpenPL(".SPXW200417P2250",profitLossMode = calculationMode) + GetOpenPL(".SPXW200417P2245",profitLossMode = calculationMode) + GetOpenPL(".SPXW200417C2895",profitLossMode = calculationMode) + GetOpenPL(".SPXW200417C2900",profitLossMode = calculationMode); plot ZeroLine = 0; PositionOpenPL.SetDefaultColor(GetColor(5)); PositionOpenPL.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM); PositionOpenPL.SetLineWeight(3); PositionOpenPL.DefineColor("Positive", Color.UPTICK); PositionOpenPL.DefineColor("Negative", Color.DOWNTICK); PositionOpenPL.AssignValueColor(if PositionOpenPL >= 0 then PositionOpenPL.Color("Positive") else PositionOpenPL.Color("Negative")); ZeroLine.SetDefaultColor(GetColor(7)); Interesting though that it does not seem to show the P/L exactly the same as what you see on the monitor tab. Anyone know why that might be? I have tried switching the ProfitLossMode.COST_BASIS to ProfitLossMode.EXECUTION_PRICE, but it still does not match. It changes obviously, but does not match.
( at April 12, 2020 8:04 pm)
0
Hi Pete is it possible to add percentage pnl as well next to the value that you have already?
( at December 21, 2020 3:12 pm)
0
Private answer

Pete, awesome response! Thank you so much. I added that code to a new study and add it to a chart. The label appears in the upper left with a “N/A” but I am assuming that is because the market is closed? I’ll test it when the market is open. Thank you.

Marked as spam
Posted by (Questions: 2, Answers: 4)
Answered on May 4, 2017 4:30 pm
0

I built and tested this while markets were closed so I don’t believe that is the issue. But I may be wrong. Be sure to read the links I provided. The GetOpenPL() function will not work on all time frames. If you adjust the chart to the correct time frame and still get ”N/A” then please reply back in the comment section below with the exact code you are using.

( at May 4, 2017 7:49 pm)
0
Private answer

Pete, thank you for your help. The attached screen shot shows the time frame I am using (which seems to be in the list from the link you provided) and also the exact code I am using.

 

Attachments:
Marked as spam
Posted by (Questions: 2, Answers: 4)
Answered on May 4, 2017 8:56 pm
0

Did you try this on PaperMoney or Live? During testing I used the Live account. When trying this on the PaperMoney side I found that this does not work at all. When using this on the Live account, the return value is zero for /CL and not ”N/A”.

( at May 5, 2017 8:43 am)
0
Yes, this was on PaperMoney. Would the widget you mentioned work on PaperMoney? If so, a screenshot would be very helpful. Pete, great site and great information. Thank you very much.
( at May 5, 2017 8:53 am)
0
Private answer

Since this technique does not work on PaperMoney, we have another way you can view current P/L data without leaving your charts. This method can only display current P/L data for a single ticker symbol at a time. The tool is called Active Trader and can be added to any of the cells within a Flexible Grid layout. See screenshot below for details on how to set one of the cells to active trader. Also attached is the settings view for the active trader showing available P/L elements to display.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 5, 2017 9:50 am
0
Thanks, Pete. You’re the best!
( at May 5, 2017 10:17 am)