Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,114 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Multi time frame trading #468358
10/02/17 10:02
10/02/17 10:02
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Hello, I am using BarPeriod=1 and would like to use different time frames like 1H, 4H, Daily on top of it. If I set TimeFrame to 240 for 4H Bars I get messy starting dates, as I understood TimeFrame does not guarantee alignment as it will just count 240 Bars from the start, I have tried using frameSync() without success too, could anyone tell me how could I get aligned Bars with starting dates for instance 00:00, 04:00, 08:00, etc...?
Thanks in advance.

Re: Multi time frame trading [Re: byakuren81] #468392
10/02/17 21:28
10/02/17 21:28
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City

void write(string name, int tf)
{
string Format = "n%s,%.5f,%.5f,%.5f,%.5f";

char FileName[40];

TimeFrame = frameSync(tf);

vars open = series(priceOpen());
vars high = series(priceHigh());
vars low = series(priceLow());
vars close = series(priceClose());

sprintf(FileName,name,strx(Asset,"/","")); // remove slash from forex pairs

if(is(INITRUN))
file_write(FileName,"Date,Open,High,Low,Close",0);
else if (frame(0))
file_append(FileName,strf(Format,
strdate("%Y-%m-%d %H:%M"),
open[0],
high[0],
low[0],
close[0]));

}

function run()
{
BarPeriod = 1;

StartDate = 20170103;
EndDate = 20170331;

write("History\%s_H1.csv",60);

write("History\%s_H4.csv",240);
}

Re: Multi time frame trading [Re: byakuren81] #468393
10/02/17 21:29
10/02/17 21:29
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
When using the code above I can get the 1H Bars but instead of getting the 4H Bars with the next write function call I get weekly Bars, could anyone tell me what am I doing wrong please ?

Re: Multi time frame trading [Re: byakuren81] #468400
10/03/17 08:20
10/03/17 08:20
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
As to my knowledge, frameSync synchronizes to a full hour, day, or week, but not to 4 hours. Although it could make sense to implement that.

Re: Multi time frame trading [Re: jcl] #468402
10/03/17 09:23
10/03/17 09:23
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Thx for your answer, I see, no problem I will find a way to customize it, however I noticed that using the code above I get hourly Bars constructed using for instance minutes Bars from 00:01 to 01:00 for the 1H Bar with date 01:00, is there a simple way of getting instead a 1H Bar with a date 1:00 but constructed from 1M Bars from 00:00 to 00:59 as if BarPeriod=60 and TimeFrame=0 ? Do I have to apply some sort of offset ?

Re: Multi time frame trading [Re: byakuren81] #468405
10/03/17 10:27
10/03/17 10:27
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
You would then get one wrong bar in any of your time frames. Price history stores M1 ticks by their close time, not their start time. If you still want to offset bars for some reason, use the TickFix variable.

Re: Multi time frame trading [Re: jcl] #468406
10/03/17 10:47
10/03/17 10:47
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Well in my opinion it is doing so that gives a wrong Bar as building 1:00 the 1H Bar in that way we consider the 1:00 1M Bar has ended which is not the case as it will end at 1:00:59...I do not understand the logic behind as Zorro builds the 1:00 1H Bar when setting BarPeriod=60 using 1M Bars from 00:00 to 00:59 which in that case is correct in my mind.

Re: Multi time frame trading [Re: jcl] #468413
10/03/17 14:31
10/03/17 14:31
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Originally Posted By: jcl
You would then get one wrong bar in any of your time frames. Price history stores M1 ticks by their close time, not their start time. If you still want to offset bars for some reason, use the TickFix variable.
This is interesting to me because the Ally broker API gives me the start time of the period, and I just used that for the field in my plugin, which now appears to be incorrect. So I should add BarPeriod/1440.0 to the DATE value, correct?

Expect an update from me soon.

Re: Multi time frame trading [Re: AndrewAMD] #468414
10/03/17 14:41
10/03/17 14:41
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
If it's T1 data, do not add anything, because T1 has no duration. Otherwise add the duration of a tick so that the timestamp corresponds to the close price. But make sure before that Ally really returns the tick start time in their API, because this is unusual. Most prices sources use the current time at the moment when the tick was sampled.

Re: Multi time frame trading [Re: jcl] #468415
10/03/17 14:53
10/03/17 14:53
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Originally Posted By: jcl
But make sure before that Ally really returns the tick start time in their API, because this is unusual. Most prices sources return the time when the tick was sampled.
I did not know this.

GET market/timesales:
"The datetime field will indicate the start time of an interval (for example: 09:25 will represent the interval from 09:25 to 09:30)."

I guess that Ally is an unusual broker.

And I did not implement ticks because I cannot get it to work. So that saves me a step. wink

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1