Saving equity curve with a different time frame

Hello,

I need to save equity curves from 1 min data with a daily time frame. Both because I don+t need the 1min resolution and, more importantly, to keep the size of the database under control.

My current code goes as follows:

SetCustomBacktestProc( "" );
PortfolioName = "Something";
/
if ( Status( "action" ) == actionPortfolio )
{
    bo = GetBacktesterObject();
    bo.Backtest(); 
    eq = bo.EquityArray;
    eqcopy = eq;
    
    TimeFrameCompress(eqcopy, inDaily);
    AddToComposite( eqcopy, PortfolioName, "X", atcFlagDeleteValues | atcFlagEnableInPortfolio );
    TimeFrameExpand(eqcopy, inDaily);
}
	

The saved equity file stil has a 1min resolution.

Not possible with an equity array or am I doing something wrong? A hidden setting somewhere?

Thanks,

Robert

SetOption("UseCustomBacktestProc", True );

Try this, untested but I think you need it.

To your main issue,
you need to assign TimeFrameCompress(eqcopy, inDaily); to a variable and then use that one.

varEqDaily = TimeFrameCompress(eqcopy, inDaily);
AddToComposite( varEqDaily, ...

This can't work for reasons I explained in the TimeFrame documentation in the manual. Please do read that.

But all that you are trying to do is not needed at all.

What you can do is to save original equity and retrieve it directly in daily interval using foreign function. Foreign function will pick correct bars and match to daily automatically.

2 Likes

Thanks, tried it, but the resulting file is screwed up (1 min resolution with empty bars except for a chunk at the end with a number of bars that I think is identical to the number of daily bars over the whole analysis period).

Thanks Tomasz for the clarification. All good as I was already using SetForeign + TimeFrameSet to pick up the equity curve later.

Of course, nothing better than reading the manual carefully :wink:

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