Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 819 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Make a run() at the end of the first bar even if StartDate = NOW #485116
01/24/22 15:16
01/24/22 15:16
Joined: Jan 2022
Posts: 58
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 58
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.
Re: Make a run() at the end of the first bar even if StartDate = NOW [Re: NorbertSz] #485117
01/24/22 15:38
01/24/22 15:38
Joined: Jan 2022
Posts: 58
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 58
Now I see that it's not a good solution, because in the last LookBack run, the last finished bar not yet exists for Zorro.
How can I force the script to run immediately, and run again normally when a bar finished?


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1