Hello,
I'm trying to understand how to properly use the TimeFrame feature. I'd like to have the capability to use multiple timeframes in some of my strategies.
The problem might be my understanding of how this works: if I'm understanding the manual correctly, it seems that BarPeriod is the smallest increment of time, and TimeFrame would be a multiple.
If that understanding is correct, then theoretically:
BarPeriod = 60
should be "roughly equivalent" to:
BarPeriod = 5
TimeFrame = 12
...except for the issues regarding day/hour boundaries that are noted in the manual.
So I tried to utilize the sample code like this:
// Let time frame start when Event == true
// f.i. frameAlign(hour() == 0); aligns to midnight
function frameAlign(BOOL Event)
{
TimeFrame = 1;
vars Num = series(0); // use a series for storing Num between calls
Num[0] = Num[1]+1; // count Num up once per bar
if(!Event)
TimeFrame = 0; // continue current time frame
else
{
TimeFrame = -Num[0]; // start a new time frame
Num[0] = 0; // reset the counter
}
}
function run()
{
BarPeriod = 5;
TimeFrame = 12;
frameAlign(minute() == 0);
...
But unfortunately this doesn't seem quite right either. I am trying to simulate BarPeriod = 60 via the code above, but the results are way off.
Thanks in advance for any tips on this
