jb
Rookie
Posts: 21
Received Likes: 3
|
Post by jb on Nov 22, 2015 16:23:52 GMT
Hi, the code below creates "~composite"+n from static variables already created.
Filter=1; Buy=0;
MinPar=1; MaxPar=60;
{ for(n=MinPar; n<=MaxPar; n++)
// Because I don't need all of them (e.g 1 to 60) //I've introduced a filter:
if(n==1 OR n==2 OR n==3 OR n==4 ) {AddToComposite( StaticVarGet("IND0"+n), suffix+StrFormat("IND0")+n, "X",1+4+8);}
if(n==11 OR n==12 OR n==13 OR n==14 OR n==15 OR n==21 OR n==22 OR n==41 OR n==42 OR n==43 OR n==44 OR n==44 OR n==45 OR n==46 OR n==47 OR n==48 OR n==49 OR n==50 OR n==52 OR n==53) {AddToComposite( StaticVarGet("IND"+n), suffix+StrFormat("IND")+n, "X",1+4+8);} }
Because the same for (...) loop is repeated several times in the AFL for other reasons) and because the numbers to be included in the for (...) changes and it is not continuous (e.g. n++) I thought to create a list and extract the relevant values from the list. Something like:
nlist="1,2,3,4,5,10,11,12,13,14";
{ for ( n = 0; ( mylist = StrExtract( nlist, n ) ) != ""; n++ ) m=StrToNum(mylist);
if(m<10) { AddToComposite( StaticVarGet("IND0"+m), suffix+StrFormat("IND0")+m, "X",1+4+8); }
if(m>9) { AddToComposite( StaticVarGet("IND"+m), suffix+StrFormat("IND")+m, "X",1+4+8); } }
but it doesn't work. Clearly I'm doing something wrong. Any help, it would be much appreciated.
|
|