Label to display Trade Value on a Debit Spread


Category:
0
0

Pete, this request is link to a previous post named “Label to display current price of debit spread”.

The original label has been great for me, so thanks for the time and suggestions. In working with this label for several months, I realize I could enhance it to include a second label that denotes the actual Mark price difference (actual profit). Today the code is tracking the value of the spread, and I would like to track the value of the trade, in other words. i.e. spreadValue – debitPaid = tradeValue So I will provide the debit paid amount as Input, and will expect to see two labels side by side, first one being the original (spreadValue) and the new one being (tradeValue).

Thanks

Marked as spam
Posted by (Questions: 5, Answers: 16)
Asked on July 5, 2019 9:29 am
88 views
0
Private answer

Whenever you reference a previous post you should include a link to that post in your question. Since you did not, I will provide a link to that post here:

https://www.hahn-tech.com/ans/label-to-display-current-price-of-debit-spread/

I will be updating the title to this question to use the most common term for this: spreadValue – debitPaid = tradeValue

That computation is referred to as Open Profit/Loss everywhere on Thinkorswim. So we need to use the correct terminology to ensure the rest of our viewers are able to search for and find this solution.

We only need to add two lines to the original code. Here is the complete solution:

input longCall = ".AMZN190719C1950";
input shortCall = ".AMZN190719C1980";
input netCost = 0.0;
def shortCallMark = close(shortCall, pricetype = "Mark");
def longCallMark = close(longCall, pricetype = "Mark");
def diff = longCallMark - shortCallMark;
AddLabel(yes, Concat("Debit Spread: ", diff), Color.WHITE);
AddLabel(yes, Concat("Open P/L: ", diff - netCost));

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on July 5, 2019 12:55 pm
0
Pete, Understood...next time I will add the link if the same scenario applies in the future. Thanks for correcting my definitions to the right naming to help the community. The indicator works well, just have one ask... Is it possible that instead of the label for the Open P/L showing RED, it shows RED if less than 0.00 and GREEN if greater than 0.00? Thanks again!
( at July 5, 2019 3:45 pm)
0
Pete, I took a logical approach to how I thought it could work, and it did. Let me know if you have any suggestions on how to clean it up and make it a more efficient code base. This is what I was able to figure out and it seems to work fine. input longCall = ".SPXW190708C3000"; input shortCall = ".SPXW190708C3010"; input netCost = 4.35; def shortCallMark = close(shortCall, pricetype = "Mark"); def longCallMark = close(longCall, pricetype = "Mark"); def diff = longCallMark - shortCallMark; def OpenP_L = diff - netCost; AddLabel(yes, Concat("Debit Spread: ", diff), Color.WHITE); AddLabel(yes, Concat("Open P/L: ", diff - netCost),(if OpenP_L > 0.00 then Color.GREEN else Color.RED));
( at July 5, 2019 8:29 pm)
0
That's exactly how I would have done it. Very good!
( at July 6, 2019 8:35 am)
0
Perfect! I will take that compliment... : ) Thanks
( at July 6, 2019 9:51 am)