Download MetaTrader 5

how to get the volume of the best bid?

To add comments, please log in or register
sd2000sd
212
sd2000sd  

I want to get the value of the best bid. EG:

if the best price of the best bid is 2000 and its volume is 5000, then I want to be able to get that 5000 value in a variable.

How can I do this?

I couldnt find anything in SymbolInfoDouble() function.

Please help.

Thanks 

Rodrigo Malacarne
Moderator
10645
Rodrigo Malacarne  
sd2000sd:

I want to get the value of the best bid. EG:

if the best price of the best bid is 2000 and its volume is 5000, then I want to be able to get that 5000 value in a variable.

How can I do this?

I couldnt find anything in SymbolInfoDouble() function.

Please help.

Thanks 

You will have to combine a for loop with the MarketBookGet() function. Something like:

//--- globals
long ask_volume = 0;
long bid_volume = 0;
MqlBookInfo BookInfo[];

//--- inside OnInit()
MarketBookAdd(_Symbol);

//--- inside OnTick() or OnTimer()
MarketBookGet(_Symbol,BookInfo);
for(int i=0;i<ArraySize(BookInfo)-1;i++)
  {
   if(BookInfo[i].type != BookInfo[i+1].type)
     {
      ask_volume = BookInfo[i].volume;
      bid_volume = BookInfo[i+1].volume;
     }
  }
To add comments, please log in or register