Basic mql5 question (beginner)

 

Hi experts,


I just have learned mql5 and don't understand something. plz, see following code and their result.  I wonder when I cut IF out, the result will change? What indicates to time?

v thid OnTick() 
  { 
   MqlTick last_tick; 
//--- 

 if(SymbolInfoTick(Symbol(),last_tick)) 
     { 
      Print(last_tick.time,": Bid = ",last_tick.bid, 
            " Ask = ",last_tick.ask,"  Volume = ",last_tick.volume); 
     } 
   else Print("SymbolInfoTick() failed, error = ",GetLastError()); 
  }

2019.03.29 16:30:25: Bid = 1.30236 Ask = 1.30244  Volume = 0

void OnTick() 
  { 
   MqlTick last_tick; 
//--- 


      Print(last_tick.time,": Bid = ",last_tick.bid, 
            " Ask = ",last_tick.ask,"  Volume = ",last_tick.volume); 

  }

1970.01.01 00:08:34: Bid = 1.795097248489361e-315 Ask = 7.955513803273653e-316  Volume = 408151257


 

Please see

SymbolInfoTick()

It returns either true or false depending on the result of the operation.

https://www.mql5.com/en/docs/marketinformation/symbolinfotick

The 

Symbol()

Links the operation to the chart symbol.

Documentation on MQL5: Market Info / SymbolInfoTick
Documentation on MQL5: Market Info / SymbolInfoTick
  • www.mql5.com
Market Info / SymbolInfoTick - Reference on algorithmic/automated trading language for MetaTrader 5
 

1970.01.01 00:08:34: Bid = 1.795097248489361e-315 Ask = 7.955513803273653e-316  Volume = 408151257

It's uninitialized values. Because last_tick is not set.

 
Thank everybody,
Can I refer to the other ticks not current one?
And how to do?
Reason: