//+------------------------------------------------------------------+ //| Test.mq5 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- if(!MarketBookAdd(Symbol())) { Print("Error MarketBookAdd ",Symbol()); return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- if(!MarketBookRelease(Symbol())) Print("Error MarketBookRelease ",Symbol()); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //| BookEvent function | //+------------------------------------------------------------------+ void OnBookEvent(const string &symbol) { //--- if(symbol==Symbol()) { double ask,bid; long ask_volume,bid_volume; if(GetBookValues(Symbol(),ask,bid,ask_volume,bid_volume)) { } } } //+------------------------------------------------------------------+ //| Expert Get Stakan values function | //+------------------------------------------------------------------+ bool GetBookValues(const string a_symbol,double &sell_price,double &buy_price, long &sell_vol,long &buy_vol) { MqlBookInfo book_price[]; if(MarketBookGet(a_symbol,book_price)) { int size=ArraySize(book_price); //--- if(size>0) { for(int i=0;i