Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 01/22/22 00:55
Lapsa's very own thread
by Lapsa. 01/21/22 08:23
Generic, dynamically growing array
by 3run. 01/18/22 15:37
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 01/18/22 15:00
Bug in NumUp/Dn
by jcl. 01/17/22 12:23
Help with plotting Lookback in Trade Mode
by degenerate_762. 01/15/22 23:43
AUM Magazine
Latest Screens
Tactics of World War I
Hecknex World
Scheherazade's Journey
Paradox Vector
Who's Online Now
5 registered members (Zheka, ozgur, AndrewAMD, gamers, NorbertSz), 168 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
kawjansen, Alex2052, AndreasTrader, spacenomad, coinpump
18731 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
FR: make log file name same as Script #485055
01/12/22 14:32
01/12/22 14:32
Joined: Jul 2017
Posts: 648
Z
Zheka Online OP
User
Zheka  Online OP
User
Z

Joined: Jul 2017
Posts: 648
When training across assets from a batch file (or just using an asset box to set Asset), one can form Script string in the Init to include an asset name to ensure training writes to different .PAR files.

However, the "_train.log" still has the name of the base script, and so of course parallel processes do not write to the same file. This info gets lost.

Setting LogNumber=strxid(Asset) does not work - strxid() gives the same result for the 'first'/only asset.

Having a switch/case to set the LogNumber is possible but cumbersome. And resulting file names are not really user-friendly.

I see following possible solutions:
- make log file name be the same as Script.
- make LogNumber a string. -> It can then be set to one's desire (e.g. Algo, BarPeriod, Asset, etc)

- automatically make log file name include an asset name - like it is with Brute force optimization.


Last edited by Zheka; 01/12/22 15:18.
Re: FR: make log file name same as Script [Re: Zheka] #485056
01/12/22 15:45
01/12/22 15:45
Joined: Jul 2017
Posts: 648
Z
Zheka Online OP
User
Zheka  Online OP
User
Z

Joined: Jul 2017
Posts: 648
Related:
If there is no asset() call in the script, Zorro correctly adds asset name to the *.PAR file, *.htm and .png files. (but not to _train.log).

However, if there is:
Code
var bcy_to_usd() {	
	asset(Asset);	
	return 0.1;
}

function run() {	
	set(LOGFILE,PARAMETERS);
	NumYears=2;
		
	if(Init) {
		//sprintf(Script,"AAA%s%s",strmid(Asset,0,3), strmid(Asset,4,3));
		Script="AAA";
			
		watch("Script=",Script);
	}
	
	var Lb = optimize(10, 10, 20,10);
	
	var rate=bcy_to_usd();
	
	LifeTime=Lb;
	
	if (priceC(0)>priceC(Lb)) enterLong();	
	
}
then there is some weird behavior. See screenshot.

Attached Files Script_simple.PNG
Re: FR: make log file name same as Script [Re: Zheka] #485061
01/13/22 07:55
01/13/22 07:55
Joined: Apr 2008
Posts: 434
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 434
Austria
First select the asset, then optimize.

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

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

By the way, for different logs: LogNumber = 1000*second(wdate(NOW));

Last edited by Petra; 01/13/22 08:45.
Re: FR: make log file name same as Script [Re: Zheka] #485063
01/13/22 10:52
01/13/22 10:52
Joined: Jul 2017
Posts: 648
Z
Zheka Online OP
User
Zheka  Online OP
User
Z

Joined: Jul 2017
Posts: 648
Ok, the example above is indeed faulty.

However, if you do this:
Code
var bcy_to_usd() {	
	asset("AUD/USD");	
	return 0.1;
}

function run() {
	
	set(LOGFILE,PARAMETERS);
	NumYears=2;
			
	asset(AssetBox);
	
	sprintf(Script,"AAA%s%s",strmid(Asset,0,3), strmid(Asset,4,3));
		
	var Lb = optimize(10, 10, 20,10);	
	
	var rate=bcy_to_usd();
	
	LifeTime=Lb;	
	if (priceC(0)>priceC(Lb)) enterLong();		
}
then the log file (and the .htm) get no extension.

And the original issue/ motivation for FR still hold: only the most recent optimization run gets written to the log file - which is a problem when optimizing many assets from a .BAT file.

Edit: just saw your last suggestion on LogNumber. This is workable, but user-unfriendly..go figure which file belongs to which asset... Why can't the log file name be the same as Script?

Last edited by Zheka; 01/13/22 11:02.
Re: FR: make log file name same as Script [Re: Zheka] #485070
01/14/22 11:49
01/14/22 11:49
Joined: Apr 2008
Posts: 434
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 434
Austria
https://manual.zorro-project.com/str_.htm

sprintf (string dest, string format, ...): int
Like strf, but fills a given char array with formatted data, and returns the number of characters written. The dest char array must have sufficient size. Parameters:
dest - destination string, a char array of sufficient length.
format - format string (see format codes).


static char Name[100];
sprintf(Name,.....);
Script = Name;

Re: FR: make log file name same as Script [Re: Zheka] #485072
01/14/22 13:31
01/14/22 13:31
Joined: Jul 2017
Posts: 648
Z
Zheka Online OP
User
Zheka  Online OP
User
Z

Joined: Jul 2017
Posts: 648
You are right, sprintf() requires a char[], thank you...I usually use strf() which worked correctly.

Still, having a log file have the same name as .par file would be quite convenient. (with the LogNumber =second() with the BAT file still some files get the same name, requiring to add timeouts....so much dancing around such a trivial issue).

Re: FR: make log file name same as Script [Re: Zheka] #485073
01/14/22 13:42
01/14/22 13:42
Joined: Jul 2000
Posts: 27,696
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,696
Frankfurt
The log file cannot have the same name as the .par file because you normally want different scripts to share the same parameter files. Like Z1, Z2, Z12.

Besides, you can easily do that by script. Use LogNumber to store different log files, and when you want individual names, just file_copy it at the end of the session.

Re: FR: make log file name same as Script [Re: Zheka] #485075
01/14/22 18:57
01/14/22 18:57
Joined: Jul 2017
Posts: 648
Z
Zheka Online OP
User
Zheka  Online OP
User
Z

Joined: Jul 2017
Posts: 648
Different scripts sharing the same parameter files is a rare exception needed for 'publishing'/end-using Z-systems. Bulk of the work is spent in development where convenience and efficiency are key.

Besides, what's the problem with scripts 'xxxxx.c' and 'zzzzz.c' both setting Script='yyyyy' to read 'yyyyy.par' in Live/Test but writing to 'yyyyy_train.log" in Train?


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