[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 862

 
FOReignEXchange:

You wanted five minutes, didn't you?

That's the way it should work. Every 5 minutes there will be a redraw, if you zero the required parameters, which are used by the indicator.


extern int timedraw=1; - this is one minute

I have done what I wanted with your help. As for the ticks, they are not very regular, but not critical, they won't be used on the history - this is a script and indicator for manual trading

three screens, or rather 4

ZS: Your code - yes indeed it is more useful for writing an indicator to be used by the EA

 
FOReignEXchange:

Except that sometimes there are no ticks for three minutes, like now. Looking at GBPUSD M1 chart, there were no 3-4 minute ticks there. You cannot use TimeCurrent() on history. Or you cannot use it in the tester because it is the current time and it does not change.

Based on the code above, we can say that the message signal will not be every 5 minutes, but every 5 bars on the minutes.


datetime TimeCurrent( )

Returns the server's last known time (last quoted time) as the number of seconds elapsed since 00:00 on January 1, 1970.

Note: In testing, the last known server time is simulated.

But still, is it simulated? Yes - it won't be exact with a not insignificant margin of error I guess, but use on the test is possible. If I do not know or do not understand something, I would be grateful if you explain.
 
usver:
But still, is it simulated? Yes - it won't be accurate with a not insignificant margin of error I guess, but use on a test is possible. If there is something I don't know or don't understand, I would be grateful if you could explain.

I think you're wrong. Wait a minute...

Ah, I remembered, TimeCurrent() cannot be used when recalculating the history of the current graph.

For example, when the following code is currently attached

                                      while(i>0)
                                      {
if (iHigh(NULL,0,i)>X)     
   {
   t=TimeCurrent();
   }
                                      i--
                                      }                                 

will remember the current real time, not the i-th bar where iHigh(NULL,0,i)>X

And in the tester I don't know.

 
FOReignEXchange:

I think you're wrong. Wait a minute...

Ah, I remembered, TimeCurrent() cannot be used when recalculating the history of the current graph.

For example, when the following code is currently attached

will remember the current real time, not the i-th bar where iHigh(NULL,0,i)>X

And in the tester I don't know.

TimeCurrent() Returns last known server time (time of last quote arrival) as number of seconds, and has nothing to do with i-bar both in tester, demo and real
 
FOReignEXchange:

I think you're wrong. Wait a minute...

Ah, I remembered, TimeCurrent() cannot be used when recalculating the history of the current graph.

For example, when the following code is currently attached

will remember the current real time, not the i-th bar where iHigh(NULL,0,i)>X

And in the tester I don't know.


Yes, it's clear. I was just confused by the phrase that TimeCurrent() cannot be used on the history and in the tester.

Won't the following code be incorrect? The time of arrival of the last quote is simulated and we use it.

int time;
if (time==0)
   time=iTime(NULL,1,0); // Точка отсчета
if (TimeCurrent()-time>=300) // Проверяем сколько времени прошло - равно ли 5 минутам
   {
      // Выполняем, что хотели
      ...
      ...
      ...
      time=0;
    }

Your solution seemed to me better than the one described above.

 
And thank you from me too. As they say, everything brilliant is simple.
keekkenen:
 
And thank you from me too. As they say, everything brilliant is simple.
keekkenen:
 
Turns out everything is genius-simple. Thanks for Notepad.
keekkenen:
 
usver:

The following code won't be wrong?

int time;

   int start()
   {

if (time==0)  time=iTime(NULL,1,0);    // Точка отсчета

if ((TimeCurrent()-time)>=300)        // Проверяем сколько времени прошло - равно ли 5 минутам
   {
      // Выполняем, что хотели
      ...
      ...
      ...
      time=0;
    }

   }

int time; must be set higher than the start time, otherwise time will always equal zero. And it should be bracketed by(TimeCurrent()-time)

The rest of the code seems to be fine. Didn't check it.

 

what is the best way to save important data/variables in case the terminal hangs up (power failure)?

- global variables of the terminal? to a file?

- how often do they need to be saved? (the last equity value and some bools are important)

Reason: