Chart Label to show Daily P/L Status (%) in real time



New member
I've been trying to script a study that would add a label up in the top left corner of a chart showing this info:
  • % up or down of today's current P/L compared with yesterday's P/L (or p/l as of 11:59p yesterday)
The goal here is to potentially better recognize when daily targets or max losses are hit.

I can get the current value from "GetNetLiq()", but struggling to calculate historic account value data.

Once this is calculated, a simple equation could be done (today's pl / yesterday's pl = value I'm looking for) and then the rest of the customization would be straightforward:
  • color based on how much up or down
  • alert based on how much up or down



On a daily chart you could use GetNetLiq() [1] to get yesterdays value. However, it doesn't seem to allow using a daily aggregation on other timeframes. I thought it wasn't possible, but this great post HERE by RobertPayne shows how to still access yesterday's values. For example, this code should get you started with the values you need, and you can go from there:
def today = GetDay() == GetLastDay();
def todayNetLiq = GetNetLiq();
def yestNetLiq = if today then yestNetLiq[1] else GetNetLiq();


New member
Does anybody know of an indicator that will display the percentage label of loss or win on the stock I purchased while in chart mode for it?

Similar threads