is(FIRSTRUN)

Posted By: chirpydog

is(FIRSTRUN) - 05/15/15 06:36

hello all,

i am trying to write a function to perform some calculations of the highs and lows of the last X bars.. This function only needs to run once at the beginning after price data and system variables ... My questions are

1. how to use flag FIRSTRUN ? i have compiling error 'FIRSTRUN' undeclared identifier for the following script

if is(FIRSTRUN) printf ("Today is friday");

2. Does it work if i declare an int variable and use it to loop through the numbers of bars ?

Eg.

int z;
for (z=0;z<11;z++) { if priceHigh(z)<priceHigh(z+1) s1=priceHigh(z+1) }

Many thanks !
Posted By: krial057

Re: is(FIRSTRUN) - 05/15/15 07:51

For fixing your syntax errors, you need to put the conditions of the if in parenthesis:
Php Code:
if(is(FIRSTRUN))
  printf ("Today is friday"); 




and

Php Code:
int z;
for (z=0;z<11;z++) { 
  if(priceHigh(z)<priceHigh(z+1))
	s1=priceHigh(z+1) ;
} 




the for loop should work.

kind regards,

Alain
Posted By: jcl

Re: is(FIRSTRUN) - 05/15/15 12:37

FIRSTRUN was for a beta version only - it is not yet defined in your Zorro version. For checking which flags your version has, click Help and look up "mode".

You can use the Bar variable for determining FIRSTRUN. It's the first run with Bar > 0.
Posted By: chirpydog

Re: is(FIRSTRUN) - 05/18/15 11:45

Thanks Alain
Posted By: chirpydog

Re: is(FIRSTRUN) - 05/18/15 11:50

Thanks jcl..

so to run the function once only after price data would be

if Bar=1 {function here..} ??
Posted By: DLively

Re: is(FIRSTRUN) - 05/18/15 13:39

As I usually mention I do not use Zorro, but being helpful as I am, I just wanted help you with your programming in general:

remember this is comparing (==) if(this==this){return;}

And this is assigning (=) x = 1;

Also as Krial057 said, Don't forget the parenthesis() around your if statement laugh
Posted By: chirpydog

Re: is(FIRSTRUN) - 05/18/15 14:53

Thanks DLively..

Yes that was my quick shot to clarify the logic... omitting the syntax..

will take note..
© 2024 lite-C Forums