Help time Seconds()

 

hello, can you reset the Seconds () variable?

my test reset does not work



 if(Open[0]!= Open[1])

    {
    seconds=Seconds();
    } 
  else if(seconds >=20) 
  {
   seconds=0
  }   
 
signal.it :

hello, can you reset the Seconds () variable?

my test reset does not work

 if ( Open[0]!= Open[1])
{
    seconds = Seconds ();
}
 
 if (seconds >= 20 ) 
{
   seconds = 0;
}   

How about this?

 
Naguisa Unada:

How about this?


thank you, it works,

but when it returns to zero it does not start until the next candle. Can it be restarted in the same candle?

 

Show all relevant code. Is seconds a global or static variable? If not than the value has been lost.

Show all relevant code. You reset it on the first tick of a new bar (probably a small number.) You zero it over 20. But do you ever modify it?

Don't just show the code and state what it is doing, state what you are trying to do. There are no mind readers here.
 
signal.it :

thank you, it works,

but when it returns to zero it does not start until the next candle. Can it be restarted in the same candle?

Since "Seconds()" enter the current seconds in "seconds", 21 - 59 seconds will be entered after 20 seconds.

To put in the elapsed seconds, you need to find another way.

For example,

datetime start_time;

int init()
{
   start_time = TimeCurrent ();
}

int start()
{
   int seconds = 0 ;
        
   if ( Open [0] != Open [1])
   {
      seconds = (int)(TimeCurrent () - start_time);
   }
        
   if (seconds >= 20 )
   {
      start_time = TimeCurrent ();
   }
}
 
Naguisa Unada :

Poiché "secondi ()" inserisci i secondi correnti in "secondi", 21 - 59 secondi saranno inseriti dopo 20 secondi.

Per mettere nei secondi trascorsi, devi trovare un altro modo.

Per esempio,


thank you


Reason: