Hello!

I have a script that I want to run immediately at start, and also when the bars finished - even the first one!
If I do this:
Code
StartDate = NOW;

the code will run immediately, but won't run again at the end of the first bar.

My solution is this:

Code
bool runStuff = false;
int runCounter = 0;

...

function run(){

	if (is(LOOKBACK)){
		runCounter++;
	}
	if (runCounter >= LookBack){
		runStuff = true;
	}

	if (runStuff){
		//...run the stuff
	}
}


Is there a more elegant way for doing an immediate run and also a normal run? Maybe a flag for it, like
Code
is(LASTLOOKBACK)

or something like this?

So runstuff would be just this:
Code
if (!is(LOOKBACK) || (is(LASTLOOKBACK)){
	//...run the stuff
}


Thank you!

Last edited by NorbertSz; 01/24/22 20:40.