Hourly bars / Daily prices

Posted By: kerplunk1899

Hourly bars / Daily prices - 04/27/20 17:26

Hi all,
could someone help me to implement the following?
I want my trades to be executed every day at 1 am based on the daily (midnight) bars prices.

Code
string datetime(){
	return strf("%02d.%02d.%02d %02d:%02d:%02d %d",day(),month(),year(),hour(),minute(),(int)second(),dow());
}


function run()
{
set(LOGFILE);
LookBack = 0;
BarPeriod = 60;
assetList("AssetsFix");
StartDate = 20200410;

asset("EUR/USD");

TimeFrame = 1;
FrameOffset = 0;
var open = priceOpen();
var close = priceClose();
printf("\n%s | Open=%.5f, Close=%.5f", datetime(), open, close);

TimeFrame = 24;
FrameOffset = 1;
var open = priceOpen();
var close = priceClose();
if(hour()==1) printf(" | Open=%.5f, Close=%.5f", open, close);

}



I thought I could use FrameOffset, but it didn't get the expected result.
I'm not sure I understood what FrameOffset does exactly. Changing its value seems to make no difference at all.

[Linked Image]

What I want, is to get the green prices and not the red ones.
Can you please help me?
Is there a more correct way to set BarPeriod/TimeFrame in order to get the result??

Thanks!!!
Posted By: kerplunk1899

Re: Hourly bars / Daily prices - 04/27/20 18:31

Code

string datetime(){
	return strf("%02d.%02d.%02d %02d:%02d:%02d %d",day(),month(),year(),hour(),minute(),(int)second(),dow());
}


function run()
{
set(LOGFILE);
LookBack = 0;
assetList("AssetsFix");
StartDate = 20200410;
BarPeriod = 60;

TimeFrame = 1;
FrameOffset = 0;
printf("\n%s | open=%.5f - close=%.5f", datetime(), priceOpen(), priceClose());

TimeFrame = 24;
FrameOffset = 17;
vars open = series(priceOpen());
vars close = series(priceClose());

if(hour()==1) printf(" | open=%.5f - close=%.5f", open[0], close[0]);


}



It seems this way I obtain what I want, but can you explain me why??
Why FrameOffset should be equals to 17?
Is is because of the default value of BarOffset (1000)?
© 2024 lite-C Forums