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
2 registered members (AndrewAMD, Nymphodora), 972 guests, and 8 spiders.
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
Series within loop #474337
10/07/18 21:39
10/07/18 21:39
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Hi guys,

I want to calculate the Open and Close price of the candle of the previous day. To do this I use the code below but my function run() is performed each 1 min (BarPeriod = 1) and I see the same value for each minute as shown here.

Code:
vars PriceC = series(priceClose()); 
vars PriceO = series(priceOpen());


I have 2 question about the point above:

1. Is it possible to skip each minute and calculate the daily value at the previous candle only once?

2. Inserting the series within loop the message is Error041: Inconsistent series!. I see the manual but I don't understand how to avoid this problem.

Code:
if(hour() == 00)
{
while(asset(loop(Assets)))
   {
   vars O = series(priceOpen());
   vars C = series(priceClose());
   }
}



Can you help me to resolve it?

Thanks in advance

Last edited by tradingest; 10/07/18 21:41.
Re: Series within loop [Re: tradingest] #474420
10/13/18 18:21
10/13/18 18:21
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
some reference?

Re: Series within loop [Re: tradingest] #474438
10/15/18 17:03
10/15/18 17:03
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Your code makes not really sense, why not using dayOpen and dayClose of the previous day?

Re: Series within loop [Re: Spirit] #474443
10/15/18 19:54
10/15/18 19:54
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Originally Posted By: Spirit
Your code makes not really sense, why not using dayOpen and dayClose of the previous day?


you can help me to find dayClose and dayOpen on previous day?

You must consider that the prices on my broker are UTC and I want to calculate open and close of previous day at UTC+2

Thanks

Re: Series within loop [Re: tradingest] #474444
10/16/18 01:38
10/16/18 01:38
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Yes you can set it with Startmarket and Endmarket, look here: http://manual.zorro-project.com/day.htm.

Re: Series within loop [Re: Spirit] #474457
10/16/18 19:44
10/16/18 19:44
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Hi Spirit,

thank again for your support but I don't understand how I can obtain what I want.
After your advice I created the code below:
Code:
#include <profile.c>

function run()
{

assetList("AssetsFix");
StartDate = 20181009;
EndDate = 2018;
StartMarket = 0000;
EndMarket = 2259;
LookBack = 1440;
BarPeriod = 1;

	while(asset(loop(Assets)))
		{
			var C = dayClose(UTC,1);
			var O = dayOpen(UTC,1);
		print(TO_WINDOW,"n Date: %02d-%02d-%02d %02d:%02d, %s , O = %f, C = %f",day(),month(),year(),hour(),minute(), Asset,O,C);
		}
}


I want obtain the Open and Close of the previous daily candle.
My function run is performed each 1 min (BarPeriod = 1) and in this way I can't obtain what I want.

The broker at UTC time and I want obtain the daily candle at UTC+2.

would you be kind enough to help me?

Thanks again

Last edited by tradingest; 10/16/18 19:44.
Re: Series within loop [Re: tradingest] #474462
10/17/18 13:22
10/17/18 13:22
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
If the time zone is 2, then set the zone to 2 in the dayclose and dayopen functions.

Re: Series within loop [Re: Spirit] #474464
10/17/18 13:24
10/17/18 13:24
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Originally Posted By: Spirit
If the time zone is 2, then set the zone to 2 in the dayclose and dayopen functions.


Even if the BarPeriod = 1?
It will take the correct value?

Is it correct the code below?
Code:
var C = dayClose(UTC+2,1);
var O = dayOpen(UTC+2,1);


Last edited by tradingest; 10/17/18 13:26.
Re: Series within loop [Re: tradingest] #474475
10/18/18 11:22
10/18/18 11:22
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Better use CET. UTC is a #define and i think you cannot add 2 to it.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1