The indicator is attached below. You will need to allow DLL imports, as TradeChart uses user32.dll, to select "All History" in the History-tab.
I have not included the .mq4-file, not because it is top-secret, but because the code uses an #include file and I want to save myself from a lot of misery of telling people how to compile the code.
Hope this will be of use for someone.
Hint: Sometimes it seems as if the figures don't add up. Play with the time frames on your chart, to force Empty4 to refresh the price data.
Update: The information panel has been extended to also display the report parameters (Start Date, Magic Number etc ...) As the extended panel was/is obscuring most of the chart, I added a close button, so that you can flip the panel away. See: There is a weird bug (or undocumented feature) in Empty4, such that if there is no indicator buffer line displayed (eg. due to a set of report parameters that do not result in any trade selection), mouse clicks on screen objects are not registered. To be more precise: they are registered, but the sparam (in OnChartEvent) is blank. In layman terms: if there is no line on the screen, the close button (on the info panel) doesn't work. Go figure.
Update 2016-09-05: (1) Fixed startup bug ... see this post. (2) Added the CurrencyFilter parameter à la TradeReport.
Update: 2016-09-07: Made a significant performance improvement, by 'sucking in' all the orders into an internal structure and sorting them in chronological order, before calculating the balance and UPL for each past candle.
Update: 2016-10-28: Removed a print statement that was left in by mistake for debugging. Thanks Thomas (tomele) for letting me know!
Update: 2017-05-07: A new version (TradeChart3) has been attached, that has improvements to the info-panel. See this Post for more information.
Update: 2017-05-31: There are two small changes:
- It now takes into account the AccountCredit() -- if your br0ker uses this --, to calculate the Account Balance
- The applied price type it uses to calculate the UPL for a candle can now be selected from a drop box. The default value is "Typical Price" (i.e. (High + Low + Close)/3 )