Gamestudio Links
Zorro Links
Newest Posts
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
Release 2.68 replacement of the .par format
by Martin_HH. 09/23/25 20:48
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 17,605 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Explaining TimeFrame #486316
07/28/22 14:22
07/28/22 14:22
Joined: Jan 2022
Posts: 70
Budapest
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 70
Budapest
Dear all,

I have the following script:

Code
#include <default.c>
function run(){
	StartDate = 20190101;
	EndDate = 20200101;
	BarPeriod = 15;

	printf("== %s:\n", strdate("%Y-%m-%d %H:%M"));
	TimeFrame = 1;
	printf("price close M15: %.5f\n", priceClose(1));
	TimeFrame = 4;
	printf("price close H1: %.5f\n", priceClose(1));
	printf("\n");
}


I use priceClose(1) because priceClose(0) gives the current price. So I would except that this way the script should run in every 15 minutes, therefore the "price close H1" should change in just every fourth run - but it changes in every running cycle.

Code
== 2019-01-02 18:45:
price close M15: 1.13307
price close H1: 1.13371

== 2019-01-02 19:00:
price close M15: 1.13284
price close H1: 1.13359

== 2019-01-02 19:15:
price close M15: 1.13287
price close H1: 1.13313


I assumed that the last candle in H1 shouldn't change every time, only in hour-turn. What am I missing?
Thank you!

Re: Explaining TimeFrame [Re: NorbertSz] #486320
07/29/22 08:50
07/29/22 08:50
Joined: Jul 2000
Posts: 28,022
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,022
Frankfurt
On this page:

https://zorro-project.com/manual/en/barperiod.htm

the topic "TimeFrame vs BarPeriod" should answer your question.

Re: Explaining TimeFrame [Re: jcl] #486322
07/29/22 16:34
07/29/22 16:34
Joined: Jan 2022
Posts: 70
Budapest
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 70
Budapest
Thank you. Yes I read that, but I did not see or understand the answer here.
I guess in this way (BarPeriod = 15, TimeFrame = 4) Zorro is always making the last H1 candle by the last 4 pieces of M15 candles, wihout considering the way of making the higher bars as it would normally do. (Normally: I mean like BarPariod = 60 and TimeFrame = 1.) But instead it's making the H1 bar by counting 4 pieces of M15 from the very last one, independently from time.

So if I want to force the hour-turning point, I need to check manually the full-hour, like this:

Code
TimeFrame = 4;
if (frame(0)){
   ...now its really a new bar data...
} else {
   ...nothing to do, it's garbage...
}


Anyways, I see a simple solution by using series instead of the price itself.
The result of this looks fine:

Code
BarPeriod = 15;
TimeFrame = 1;
vars PriceM15 = series(priceClose(0));
TimeFrame = 4;
vars PriceH1 = series(priceClose(0));
printf("== %s:\n\n", strdate("%Y-%m-%d %H:%M"));
printf("%.5f - %.5f", PriceM15[0], PriceH1[0]);

Last edited by NorbertSz; 07/29/22 17:28.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1