Eyl
New member
Is it possible to get the profit and loss as a label on active traders for options?
This exists on shares, but I haven't been able to find it with options. Below is code managed to scalp looking through online resources.
I have searched through the threads as well. I am aware of just setting it on the watchlist, but I want to see it as a label on the chart. If anyone can help. Thank you
for example;
.SPY240129P486
This exists on shares, but I haven't been able to find it with options. Below is code managed to scalp looking through online resources.
I have searched through the threads as well. I am aware of just setting it on the watchlist, but I want to see it as a label on the chart. If anyone can help. Thank you
for example;
.SPY240129P486
Code:
declare lower;
input showlabel = yes;
def qty = GetQuantity();
def avgCost = GetAveragePrice();
def opencost = qty * avgCost;
def netLiq = qty * close;
AddLabel(showlabel, "Avg: " + avgCost, color.white);
AddLabel(showlabel, "Qty: " + qty, color.white);
###################################################################
#######################
plot pnlRatio = if avgCost != 0 then (netLiq / opencost) else 0;
plot pnlValue = (netLiq - opencost)*100 ;
addLabel(showlabel, " " + AsPercent(pnlRatio), if pnlRatio > 0 then color.green else if pnlRatio < 0 then color.red else color.white);
AddLabel(showlabel, " $" + pnlValue, if pnlValue > 0 then color.green else if pnlValue < 0 then color.red else color.white);