Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
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
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,655 guests, and 7 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
Page 2 of 2 1 2
Re: I may be stupid, but I'm not crazy! caution LONG! [Re: Pork] #429948
09/20/13 17:40
09/20/13 17:40
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Hi Pork,

Yes, I did run it. The if IS executed and buff is loaded. Without the "#" in the printf I can see the file contents in the Zorro window, even though it doesn't show in the log since it isn't active yet. For example, this works:

Code:
#define H1 (BarPeriod/60)
bool FirstTime=true;
function run() {
	BarPeriod	= 60;
	TimeFrame	= H1;
	StartDate	= 20080102;
	EndDate		= 20080131;
	string 	buff;
	if(FirstTime){
		buff	= file_content("History\\atestfile.txt");
		printf("\nFirstTime-Bar,buff=%i,%s",Bar,buff);
		FirstTime=false;
	}
}



If you prefer the int route, this also works:

Code:
#define H1 (BarPeriod/60)
int FirstTime=0;
function run() {
	BarPeriod	= 60;
	TimeFrame	= H1;
	StartDate	= 20080102;
	EndDate		= 20080131;
	string 	buff;
	if(FirstTime==0){
		buff	= file_content("History\\atestfile.txt");
		printf("\nFirstTime-Bar,buff=%i,%s",Bar,buff);
		FirstTime=1;
	}
}



The reason your var version prints in the log is because as Spirit said you're entering the if twice. The first time on the first run with firsttime initialized to 0, and the second time on the second run since on the first run prices haven't been loaded yet and so setting firsttime to priceClose() sets it again to 0.

If your point is you need to see the buff printout in the log, you'll need to delay until the log is active. As you found out, using empty priceClose() works. This is another way that allows you to pick the bar:

Code:
#define H1 (BarPeriod/60)
int FirstTime;
function run() {
	BarPeriod	= 60;
	TimeFrame	= H1;
	StartDate	= 20080102;
	EndDate		= 20080131;
	string 	buff;
	if(is(INITRUN)) FirstTime = 0;
	if(FirstTime==1){
		buff	= file_content("History\\atestfile.txt");
		printf("#\nFirstTime-Bar,buff=%i,%s",Bar,buff);
	}
	FirstTime	+= 1;
}



HTH.

Re: I may be stupid, but I'm not crazy! caution LONG! [Re: jcl] #429950
09/20/13 17:46
09/20/13 17:46
Joined: Jun 2013
Posts: 41
Ohio, USA
P
Pork Offline OP
Newbie
Pork  Offline OP
Newbie
P

Joined: Jun 2013
Posts: 41
Ohio, USA
I have edited my post to say that I get it.
You may ignore my previous post.
Thanks to all of you for your patience and understanding.
They say old dogs can't be taught new tricks.
Well, they can. it just takes longer sometimes.
P

Last edited by Pork; 09/20/13 17:57.
Re: I may be stupid, but I'm not crazy! caution LONG! [Re: Pork] #429953
09/20/13 17:59
09/20/13 17:59
Joined: Jun 2013
Posts: 41
Ohio, USA
P
Pork Offline OP
Newbie
Pork  Offline OP
Newbie
P

Joined: Jun 2013
Posts: 41
Ohio, USA
If you read my previous post, I have now edited it.
Thankyou for your patience and undestanding.
P

Page 2 of 2 1 2

Moderated by  Petra 

Gamestudio download | 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