Daily bars

Posted By: kerplunk1899

Daily bars - 05/13/20 09:26

Hi all,

could you help me?
I want to get daily bars whose open price is the first price of that day and the close price is the last one.
I'm struggling with the weekend and with the close price of the friday bar.
I want to exclude the sunday price AT ALL.
To do this I have set: StartWeek = 10000; EndWeek = 52359;
Also I placed the BR_WEEKEND flag.

Here's the code I use. I set an hourly BarPeriod and the TimeFrame = frameSync(24) to get the daily prices.

Everything seems correct except from the friday bar printed on monday.
Its close price is actually the midnight price of sunday. I would like to exclude the sunday getting the last available price of friday as the close price of the friday bar.
Is this possible?

Code
function run()
{
set(LOGFILE);
assetList("AssetsFix");
BarPeriod = 60;
BarOffset = 0;
BarMode = BR_WEEKEND;
Weekend = 2;
StartWeek = 10000;
EndWeek = 52359;
StartDate = 20200401;
asset("EUR/USD");

printf("\n%s", datetime());

/*HOUR PRICES*/
printf(" | open=%f - close=%f | ", priceOpen(), priceClose());

TimeFrame = frameSync(24);
vars open = series(priceOpen());
vars close = series(priceClose());
TimeFrame = 1;

/*DAILY PRICES*/
printf(" | open=%f - close=%f | ", open[0], close[0]);

}


Thanks
Posted By: Petra

Re: Daily bars - 05/17/20 12:23

What you probably need is BR_SLEEP for ignoring the Sunday prices. But I don't know if this works also in the backtest, in the manual BR_SLEEP seems to be for live trading. Try it out.
Posted By: jcl

Re: Daily bars - 05/18/20 07:55

BR_SLEEP is for live trading. It would make sense to implement it also for the backtest. Until then, just let the week end on Sunday, not Monday, but don't trade on the Sunday bar. The Sunday prices are then not included in the Monday bar.
© 2024 lite-C Forums