question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MT4] SymbolInfoTick() does not return Last and Volume

See original GitHub issue

I noticed this before, and thought it was an MT4 issue, but in their docs, it show that this info should be available. I don’t see either Volume or Last coming from the SymbolInfoTick() response.

2020.11.14 00:54:38.034	MtApi_debug EURUSD,M15: OnRequest: Response = {"ErrorCode" : 0,"Tick" : {"Ask" : 1.18335,"MtTime" : 1605311819,"Last" : 0,"Volume" : 0,"Bid" : 1.1832}}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vdemydiukcommented, Nov 27, 2020

@eabase This is not might be an issue. You can check MQL function in MtApi.mq4 and find that function void ExecuteRequest_SymbolInfoTick(JSONObject *jo, string &response) fills all the fields of MqlTick (Volume and Last also).

Please check answer #10 to similar question on MQL5 forum: https://www.mql5.com/en/forum/338238

0reactions
eabasecommented, Dec 1, 2020

Indeed seem to be a problem with MT4/5 not populating their returned arguments.

void OnTick()
  {
   long        symbol_volume = SymbolInfoInteger(Symbol(),SYMBOL_VOLUME);
   double symbol_volume_real = SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_REAL);
   long tick_volume_array[],real_volume_array[];

   MqlTick m_tick;
   if(!SymbolInfoTick(Symbol(),m_tick) 
      || CopyTickVolume(Symbol(),Period(),0,1,tick_volume_array)!=1 
      || CopyRealVolume(Symbol(),Period(),0,1,real_volume_array)!=1)
      return;

   Print(TimeToString(m_tick.time,TIME_DATE|TIME_MINUTES),",",
         " m_tick.bid ",DoubleToString(m_tick.bid,Digits()),
         " m_tick.ask ",DoubleToString(m_tick.ask,Digits()),
         " m_tick.volume ",IntegerToString(m_tick.volume),
         " m_tick.volume_real ",DoubleToString(m_tick.volume_real,0),
         " SYMBOL_VOLUME ",IntegerToString(symbol_volume),
         " SYMBOL_VOLUME_REAL ",DoubleToString(symbol_volume_real,0),
         " tick_volume_array[0] ",IntegerToString(tick_volume_array[0]),
         " real_volume_array[0] ",IntegerToString(real_volume_array[0]));
  }

For performance consideration, don’t really want to triple my API/EA requests just to get that volume for ticks…

Read more comments on GitHub >

github_iconTop Results From Across the Web

tick volume why is 0 - Symbols - MQL4 and MetaTrader 4
hi guys i run this code void OnTick() { MqlTick last_tick; //--- if(SymbolInfoTick(Symbol(),last_tick)) { Print(last_tick.time,": Bid = " ...
Read more >
SymbolInfoString - Market Info
Returns true or false, depending on the success of a function. If successful, the value of the property is placed in a placeholder...
Read more >
Tick separate volume trading - coder needed | Page 6
The variable of the MqlTick type allows obtaining values of Ask, Bid, Last and Volume within a single call of the SymbolInfoTick() function....
Read more >
Automated Orders don't work, but also give no useful error ...
I'm trying to place an automated order in MetaTrader 4 using an EA on a Demo account. The order does not get placed,...
Read more >
How To Download Tick Data in MetaTrader 4 & 5
This post describes how to download/save tick data offline, from both MT4 and MT5. Code samples (MetaTrader indicators) have also been ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found