Ask, bid and volume from various assets

 

I need to get the ask, bid and volume from various assets. I'm looking at the book. But apparently this only works if the EA is attached to the asset. Does anyone have any ideas?

   MarketBookAdd(units);
   MqlBookInfo       BookInfo_unit[];
   MarketBookGet(units,BookInfo_unit);
   for(int i=0;i<ArraySize(BookInfo_unit)-1;i++)
       {
       if(BookInfo_unit[i].type != BookInfo_unit[i+1].type)
         {
         volume_ask_unit = BookInfo_unit[i].volume;
         ask_unit = BookInfo_unit[i].price;
         volume_bid_unit = BookInfo_unit[i+1].volume;
         bid_unit = BookInfo_unit[i+1].price;
         }
       }
    MarketBookRelease(units);

 
Otavio Konmin Clemente:

I need to get the ask, bid and volume from various assets. I'm looking at the book. But apparently this only works if the EA is attached to the asset. Does anyone have any ideas?

It works if attached, sure. 

You will be able to access any asset info for assets which are visible/added on Market Watch window.


Please clarify your question. 

Reason: