title: How to delay orders in pine script by numbers of minutes in 1hr timeframe?
body: <p>I'm trying to delay entry orders by minutes.
  ex: At 12:00 pm the macd line crossover signal line, but I wanna start entry.order at 12:02 pm.
  So I tried the following code</p>
  <pre><code>//@version=4
  strategy(&quot;delay2&quot;,calc_on_every_tick=true)
  
  i_qtyTimeUnits  = input(2, &quot;Quantity&quot;, minval = 0) 
  
  int _timeFrom_ = na        
  _timeFrom_ := i_qtyTimeUnits*60*1000
  
  // Entry conditions.
  fastLength = input(12)
  slowlength = input(26)
  signalLength = input(9)
  MACD = sma(close, fastLength) - sma(close, slowlength)
  signal = sma(MACD, signalLength)
  delta = MACD - signal
  bool goLong = delta&gt;0
  bool goShort = delta&lt;0
  
  float entrytime = na
  float delaytime = na
  entrytime := if goLong
      nz(entrytime[1], time)
  delaytime := if entrytime&gt;0
      nz(delaytime[1], entrytime+_timeFrom_)
  delayElapsed = time&gt;=delaytime
  
  plot(entrytime)
  plot(delaytime)
  plot(time)
  
  if goLong and delayElapsed
      strategy.entry(&quot;Long&quot;, strategy.long, comment=&quot;Long&quot;)
      strategy.close('short', when = goShort)
  </code></pre>
  <p>I've plotted and checked that delayElapsed is true, but it just doesn't work,please help.</p>