why is it not suitable for init() ?
You can log the time into a global variable using GlobalVariableSet().. this will store the time and you can work off of that. Alternatively, static variables are an option..
init() { //... static datetime only_once = TimeCurrent() //... } start() { //... if(TimeCurrent() > only_once) //..dont do whatever //...
then again if youre doing that, why not just put the code in init() ..Id be hard pressed to find code thats not suitable for init() somehow
I would declare the datetime var globaly but not as in GlobalVariableSet(), that brings up a question I been meaning to ask for a while, when describing global variables on the forum, how to differentiate between the kind of gloabal variable within a mql4 program code, and the other kind of global variable as declared using GlobalVariableSet() ? In other words how to avoid confusion when talking about global variables ?
Anway I would decare datetime variable globably so it can be used in other functions, then initialize it to the current time in init()
int start ()
{
//< Routine that run only once >```````````````````````//< >
static int iFlag = 0 ; if ( iFlag == 0 ) { iFlag = 1 ; //< >
//< >
//< Code to run once > //< >
Alert ( "Hi!" ) ; //< >
// ... //< >
//</Code to run once > //< >
} //< >
//</Routine that run only once >```````````````````````//< >
}
Hey, everyone!
I'm new here and came to gain new knowledge.
Did anybody hear anything about Anna Monti and her forex freebot ? There are a lot of stuff in the web but nothing specific at the same time.
waiting for reply :)
Dam spammer. This exact post appears on many boards.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to execute a particular piece of script only once.
It doesn't suitable to sit in the init() part of the script
So to do that I would like to know if there is a command_type that will only run once?
or
maybe there is some variable that keeps the exact time when the script initiated?
James