Account Net Liquid + Performance Comparison Labels
A very underutilized but useful tool within TOS is the AccountNetLiq study. This gives you a chart throughout time of your account balance, so you can see what it is now vs what it was at any point in the past. But what if you want to compare your account's performance to a certain stock, index, etc?
First we will be extracting all of the AccountNetLiq study script:
declare lower;
plot AccountNetLiq = GetNetLiq();
plot ZeroLine = 0;
AccountNetLiq.SetDefaultColor(GetColor(1));
AccountNetLiq.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
AccountNetLiq.SetLineWeight(3);
AccountNetLiq.DefineColor("Positive", Color.UPTICK);
AccountNetLiq.DefineColor("Negative", Color.DOWNTICK);
AccountNetLiq.AssignValueColor(if AccountNetLiq >= 0
then AccountNetLiq.Color("Positive")
else AccountNetLiq.Color("Negative"));
ZeroLine.SetDefaultColor(GetColor(7));
ZeroLine.Hide();
Next will add the following script:
def RoR_1Year = 100*(accountNetLiq-accountNetLiq[252])/accountnetLiq[252];
def RoR_6Month = 100*(accountNetLiq-accountNetLiq[126])/accountnetLiq[126];
def Ror_1Month = 100*(accountNetLiq-accountNetLiq[21])/accountnetLiq[21];
input symbol = "SPX";
def symbolclose = close(symbol);
def symbol1year = 100*(symbolclose- symbolclose[252])/symbolclose[252];
def symbol6month = 100*(symbolclose- symbolclose[126])/symbolclose[126];
def symbol1month = 100*(symbolclose- symbolclose[21])/symbolclose[21];
addlabel(1, " 1Y RoR: " + round(RoR_1Year, 1) + "% ", if RoR_1Year >= 0 then color.green else color.red);
addlabel(1, " " + symbol + " 1Y: " + round(symbol1year, 1) + "% ", if symbol1year >= 0 then color.green else color.red);
addlabel(1, " 6m RoR: " + round(ror_6Month, 1) + "% " ,if RoR_6month >= 0 then color.green else color.red);
addlabel(1, " " + symbol + " 6m:" + round(symbol6month, 1) + "% ", if symbol6month >= 0 then color.green else color.red);
addlabel(1, " 1m RoR: " + round(RoR_1month, 1) + "% " ,if RoR_1month >= 0 then color.green else color.red);
addlabel(1, " " + symbol + " 1m: " + round(symbol1month, 1) + "% ", if symbol1month >= 0 then color.green else color.red);
Once we put it all together, we have the same graph as before, as well as the performance comparison labels, in this case being compared to SPX, the S&P 500 index. They will change color based on if they are positive or negative, and show us the % change of our own portfolio, as well as the selected symbol for 1 Year, 6 months, and 1 month.
When we enter the settings for this study, we can change which symbol we are comparing our portfolio with. Now the same labels will display the performance of the new symbol, in this case AAPL.