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
5 registered members (AndrewAMD, Nymphodora, Quad, TipmyPip, Imhotep), 852 guests, and 5 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
advideLong & script #480671
06/25/20 17:07
06/25/20 17:07
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

I have one script where I generate rules
Code
scritp gen.c

function run()
{
  	assetList("Assets4");
        string cSymbol=strx(Asset,"/","");
	Script = strf("AlfaEE_%s",cSymbol);

     ...
        vL = adviseLong(PATTERN+FAST,0,
}


and in second - where I use rules from first (gen.c). But I cannot get, if second script use this rules or not
Code
script second.c
function run()
{
  	assetList("Assets4");
        string cSymbol=strx(Asset,"/","");
	Script = strf("AlfaEE_%s",cSymbol);


I change name the script to:
Script = "AlfaEE_error";

but I dont see any error and script second.c runnign without problem. But no open any order.




Last edited by Grat; 06/25/20 17:16.
Re: advideLong & script [Re: Grat] #480672
06/25/20 21:14
06/25/20 21:14
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Never use Script = strf(), chances of failure are about 100%. Use a real char buffer instead.

Re: advideLong & script [Re: Grat] #480673
06/26/20 05:40
06/26/20 05:40
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Ok,

I have rules from GEN.c store in:
AlfaEE_GBPUSD_GBPUSD.c

Now, I run second script with this:
cSymbol=strx(Asset,"/",""); // GLOBAL var
string cPom=strf("AlfaEE_%s",cSymbol);
Script = cPom;
printf("\nUse script %s",Script);

and in the LOGFILE I don't any problem.

I change the this:
string cPom=strf("eeeAlfaEE_%s",cSymbol);
Script = cPom;

and also not get any problem in the log file.


Is a possible get any info, which rules load in the script?

Re: advideLong & script [Re: Grat] #480674
06/26/20 13:21
06/26/20 13:21
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
You didn't do what I said to do. You did not create a char buffer. Take a look at this code and its output:
Code
void main(void){
	string a = strf("apple");
	string b = a;
	char c[20];
	strcpy(c,a);
	string d = c;
	printf("\na1: %s",a);
	printf("\nb1: %s",b);
	printf("\nc1: %s",c);
	printf("\nd1: %s",d);
	int i;
	for(i=0;i<100;i++){
		strf("banana%d",i);
	}
	printf("\na2: %s",a);//undefined behavior (bad)
	printf("\nb2: %s",b);//undefined behavior (bad)
	printf("\nc2: %s",c);//defined behavior (good)
	printf("\nd2: %s",d);//defined behavior (good)
}

/*output:
a1: apple
b1: apple
c1: apple
d1: apple
a2: banana99
b2: banana99
c2: apple
d2: apple
*/
Note that a and b were ruined, whereas c and d remained intact.

By the way, strx() also returns temporary pointers, so you can expect similar problems.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1