Gamestudio Links
Zorro Links
Newest Posts
Links dont work
by HamzaAhmed. 05/19/22 08:07
Unable to make new structures
by vinitrinh. 05/19/22 06:04
C++ scripts
by AndrewAMD. 05/18/22 16:43
Help with sorting data array
by degenerate_762. 05/18/22 12:24
How to use dataFromCSV
by AndrewAMD. 05/16/22 16:43
MT4, handling requote issues
by Grant. 05/15/22 00:04
Lapsa's very own thread
by Lapsa. 05/14/22 22:59
AUM Magazine
Latest Screens
DEAD TASTE
Tactics of World War I
Hecknex World
Scheherazade's Journey
Who's Online Now
6 registered members (Quad, Grant, degenerate_762, 3run, HamzaAhmed, vinitrinh), 287 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Abdou, quandr, SGB1962, QuadraQuant, IcairDap
18781 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: 19
N
NorbertSz Offline OP
Newbie
NorbertSz  Offline OP
Newbie
N

Joined: Jan 2022
Posts: 19
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: 19
N
NorbertSz Offline OP
Newbie
NorbertSz  Offline OP
Newbie
N

Joined: Jan 2022
Posts: 19
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