Generate bars whenever there is data

Posted By: JamesHH

Generate bars whenever there is data - 10/23/21 16:35

I want to backtest a strategy, generating bars for whenever there is data for that bar.

Following the BarMode documentation, e.g. "For trading assets even at weekends, such as cryptocurrencies, reset BR_WEEKEND before sampling bars", I put this at the beginning of my script:

Code
	if (is(INITRUN)) {
		features = malloc(num_features * sizeof(var));
		set(BR_MARKET | OFF);
		set(BR_WEEKEND | OFF);
	}


However, comparing with an export from the ZHistoryEditor, I see that the script is skipping thousands of bars (I presume on the weekend but I have not carefully checked yet).

Also, according to the docs, after resetting BR_WEEKEND, I would expect StartWeek and EndWeek to have no effect, yet changing these does affect the number of bars generated.

What am I misunderstanding, or is there possibly a bug here?
Posted By: AndrewAMD

Re: Generate bars whenever there is data - 10/23/21 18:04

set() does not configure BarMode. And don’t use OFF. Use the setf and resf macros on the BarMode int.
Posted By: JamesHH

Re: Generate bars whenever there is data - 10/24/21 11:24

You are right, it does say to use setf and resf in the BarMode documentation. However, it gave me the exact same result.

I will double-check my input .t6 file...
Posted By: JamesHH

Re: Generate bars whenever there is data - 10/24/21 18:28

It was an issue with an incorrect StartDate, btw. So it was in fact generating all bars.
© 2024 lite-C Forums