Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Miska), 755 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
lorikob361, LucasJoshua, Baklazhan, Hanky27, firatv
19054 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: 58
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 58
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: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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: 58
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 58
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