Hello Good time I wrote a multi-time program that I want to give an alarm in 15 minutes, for example, so that the next candle of the program does not run. Please help me
Hello Good time I wrote a multi-time program that I want to give an alarm in 15 minutes, for example, so that the next candle of the program does not run. Please help me
EDIT: if you're concerned about the opening of a new bar, just keep the value of iTime(NULL, PERIOD_M15, 0) in a global/static variable. From there, just call iTime(NULL, PERIOD_M15, 0) checking for a greater value than the value you have stored. If it's greater, store the new value in the global/static variable and execute the rest of your code.
Just going to leave this here since I already wrote it up
----------------
Sets a 15min timer from when the program loads
//--- Globaldatetime alarmTime;
//--- OnInitconstdatetime time = TimeCurrent();
alarmTime = time + (PERIOD_M15 * 60);
//--- OnCalculate / OnTickconstdatetime now = TimeCurrent();
constbool isAlarm = now >= alarmTime;
if (isAlarm) {
alarmTime = now + (PERIOD_M15 * 60);
//--- do something
}
For every 15min based off start of the hour (ex: 10:00, 10:15, 10:30, 10:45, etc.)
constdatetime time = TimeCurrent() - (TimeCurrent() % 60); //--- remove seconds from TimeCurrentconstbool is15min = time % (PERIOD_M15 * 60) == 0; //--- if remainder of time / 15min == 0, it's s 15min intervalif (is15min) {
// do something
}
Alexander Martinez #: Sets a 15min timer from when the program loads
constdatetime time = TimeCurrent();
Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:
Terminal starts.
Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
OnInit is called.
For indicators OnCalculate is called with any existing history.
Human may have to enter password, connection to server begins.
New history is received, OnCalculate called again.
New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Hello Good time I wrote a multi-time program that I want to give an alarm in 15 minutes, for example, so that the next candle of the program does not run. Please help me
Hello Good time I wrote a multi-time program that I want to give an alarm in 15 minutes, for example, so that the next candle of the program does not run. Please help me
EDIT: if you're concerned about the opening of a new bar, just keep the value of iTime(NULL, PERIOD_M15, 0) in a global/static variable. From there, just call iTime(NULL, PERIOD_M15, 0) checking for a greater value than the value you have stored. If it's greater, store the new value in the global/static variable and execute the rest of your code.
Just going to leave this here since I already wrote it up
----------------
Sets a 15min timer from when the program loads
For every 15min based off start of the hour (ex: 10:00, 10:15, 10:30, 10:45, etc.)Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet: