Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,455 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 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