Execution prior to/outside the Scope of the 'Start' function?

 

Execution scope: I understand that unless I code it in otherwise, everything within the scope of the 'start' function executes on every tick.

But what about outside the scope of the Start function? Such as code that is often seen prior to this? Looking at some working EA samples, I don't see execution control outside of the Start function. Does it execute on every new bar or ???

 
Please don't double post, already asked and answered . . . https://www.mql5.com/en/forum/139109
 
RaptorUK:
Please don't double post, already asked and answered . . . https://www.mql5.com/en/forum/139109

??? Raptor This isn't the same question at all. This one has to do with the frequency of execution (& control?) of functions outside of the scope of the START function while the link you posted has specifically to do with the closing of only one type of market order without closing them all.

 

Do you mean code in the init() function ? It is executed once only when the EA/Indicator is loaded

 
FourX:

Execution scope: I understand that unless I code it in otherwise, everything within the scope of the 'start' function executes on every tick.

But what about outside the scope of the Start function? Such as code that is often seen prior to this? Looking at some working EA samples, I don't see execution control outside of the Start function. Does it execute on every new bar or ???

You already asked . . .

"But what about outside the scope of the Start function such as code that is often seen prior to this? Does it execute on every new bar or do I have to code in specific execution code?"

. . . here: https://www.mql5.com/en/forum/139109

 
RaptorUK:

You already asked . . .

"But what about outside the scope of the Start function such as code that is often seen prior to this? Does it execute on every new bar or do I have to code in specific execution code?"

. . . here: https://www.mql5.com/en/forum/139109


Point taken Raptor. I did bring it up there. But I don't see any clear explanation of this: The execution of code that does not fall within the scope of these. Hence my posting of this topic specifically about this. I still don't know what controls the execution of code that is NOT contained within the scope of and is not contained within either the 'Init' nor the 'Start' functions. Unless programmed otherwise: such as only at the start of a new bar, everything within the scope of the Start function executes every time their is a new tick. As stated and I am aware of, anything within the scope of the 'init' functions runs once at the start of the program. But my question isn't about the execution of code within either of these functions and situations. It is about what controls and triggers activation and operation of code that does NOT fall within the scope and realm of these two? Such as what one often finds at the start of a program after the Init (& sometimes the DeInit) functions but before the 'Start' function.
 
All user defined functions are coded outside of both the start() function and the init() function
 
FourX:

Execution scope: I understand that unless I code it in otherwise, everything within the scope of the 'start' function executes on every tick.

But what about outside the scope of the Start function? Such as code that is often seen prior to this? Looking at some working EA samples, I don't see execution control outside of the Start function. Does it execute on every new bar or ???

Start(), init(), deinit(), and user defined functions are just that functions. They do nothing unless called. Mt4 calls the first three (per tick, on load, on chart change, etc.) If your code doesn't call your functions they do nothing.
 
SDC:
All user defined functions are coded outside of both the start() function and the init() function
Yep. Thanks
 
WHRoeder:
Start(), init(), deinit(), and user defined functions are just that functions. They do nothing unless called. Mt4 calls the first three (per tick, on load, on chart change, etc.) If your code doesn't call your functions they do nothing.

Hi WHR et al,

I'm aware of the triggering in the first three. But as I've said, I've seen numerous EAs that have a great deal of code, functions and expressions after the init(), deinit() and before the Start(). So all of these would be strictly as the logic is programmed as opposed to every tick as those within the Scope of the Start() section. An example of this would be at the changing of a Bar, etc ?

So do I more or less have the scoop on the Scope? Going by the content in this thread, do you folks think that there are other aspects that I seem to have missed out on and am unaware of as of yet?

 

One MORE time. There is no changing of a bar, etc. There is ONLY, per tick, Mt4 calls start(). Nothing else happens, PERIOD, unless you do it in start or call them from start.

If YOU want to detect a new bar, then YOU must code a check for that. E.g.

void OnNewBar(){
   :
}
int start(){
   static datetime Time0; if (Time[0] != Time0){ Time0 = Time[0]; OnNewBar(); }
   onTick();
}
// functions can be placed in any order.
void OnTick(){
    :
}