Posted By: NorbertSz
Make a run() at the end of the first bar even if StartDate = NOW - 01/24/22 15:16
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:
the code will run immediately, but won't run again at the end of the first bar.
My solution is this:
Is there a more elegant way for doing an immediate run and also a normal run? Maybe a flag for it, like
or something like this?
So runstuff would be just this:
Thank you!
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!