Time of day profitability chart

Good day!

After extensive searching I'm at a loss of how to implement a time of day profitability chart.
I want to know the total equity at each minute.
From backtest OR exploration since I have not managed to implement either successfully. I ended up going with backtest in the end.

I have attached an example here of what I'm trying to achieve:

It does say "Cumulative PnL in $" on the y-axis but I believe the "Cumulative Equity in $" would be better, so that's what I want to code.
I want the x-axis to be the same.

My AFL-proficiency is OK as long as we are doing high level things, but I believe I need to do some kind of CBT-work here and I am struggling, and when it comes to thing like low level graphics or matrix functions I'm yet unfortunately even worse.

I got some inspiration from this thread, which I think is the path, but there's no implementation details so I'm stuck experimenting:

The examples of this page is doing something similar, but I can't translate it:

I believe this simple code stores the time and the equity of each bar in a matrix.
The backtest is being run on the 1-minute timeframe.
The buy or sell rules are not relevant here, I believe.

SetOption( "UseCustomBacktestProc", True );
if( Status( "action" ) == actionPortfolio ) {

    bo = GetBacktesterObject();
    bo.PreProcess(); // Initialize backtester
    
	rows 		= BarCount;
	cols 		= 2;
	TimeNumEqMx 	= Matrix(rows, cols);
	
	time = 0;
	eq = 1;

    for( bar = 0; bar < BarCount; bar++ ) {
        bo.ProcessTradeSignals( bar );

		tn = TimeNum();
		TimeNumEqMx[bar][time] = tn[bar]; 
        TimeNumEqMx[bar][eq] = bo.Equity;       

		// ..?
		// I want to aggregate the equity of each time in a way so that the aggregate can be plotted.
                // I'm hoping this can be achieved using mx functions.
                // Then plot.
    }

    bo.PostProcess(); // Finalize backtester    
}

My goal with this post is:

  • to be able to create the plot in the attached image, so that I can deduce which hours seem to be profitable.
  • to understand if I am on the right path. I don't understand if I should use an exploration or a backtest. I'm using a backtest as I figured this would be the way to get equity and time combined somehow.
  • To get help with the implementation. I know that the code is very sparse and I understand if it is annoying to help me solve this issue, but I'm hoping someone might have an idea, or might have solved a similar issue beforehand.

I've read the documentation for the custom backtester.
I think I've read every single thread on graphics on this forum.
I've tried to read the threads regarding matrices and graphics.
I've googled too much.

I hope I am asking a good question. If not, I'll try to do better.

Best, W

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.