Скачать MetaTrader 5

стакан заявок FORTS

Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Vitalya Antonov
1378
Vitalya Antonov  

Всем доброго времени суток!

Запускаю следующий код:

#define SECURITY "LKOH-9.14"

int OnInit()
{
   if (!MarketBookAdd(SECURITY))
      Print("book wasn\'t added");
      
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
   MarketBookRelease(SECURITY);
}

void OnBookEvent(const string &symbol)
{
   MqlBookInfo priceArray[];
   if (!MarketBookGet(symbol, priceArray))
   {
      Print("no book was got on "+symbol);
      return;
   }
}

В результате в журнал выходит:

MJ      0       11:29:42.893    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
NL      0       11:29:43.581    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
DG      0       11:29:43.581    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
EN      0       11:29:43.768    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
MP      0       11:29:43.784    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
HK      0       11:29:43.831    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
RM      0       11:29:43.956    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
ID      0       11:29:45.175    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
JO      0       11:29:45.190    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
HQ      0       11:29:45.206    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
RH      0       11:29:45.206    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
KS      0       11:29:49.988    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
FE      0       11:29:50.066    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
ML      0       11:29:50.456    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
NF      0       11:29:50.738    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
II      0       11:29:53.206    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
DP      0       11:29:53.238    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
HJ      0       11:29:53.300    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
CM      0       11:29:53.581    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
DD      0       11:29:53.597    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
DN      0       11:29:53.753    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
IQ      0       11:29:53.769    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
OK      0       11:29:53.800    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
RR      0       11:29:53.863    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
LE      0       11:29:54.363    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
JO      0       11:29:54.363    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
PF      0       11:29:54.363    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
NI      0       11:29:54.363    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
GS      0       11:29:54.425    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
PJ      0       11:29:54.488    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
HL      0       11:29:54.503    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
IG      0       11:29:54.535    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
RN      0       11:29:54.550    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
GP      0       11:29:54.566    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
CK      0       11:29:54.597    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
LR      0       11:29:55.410    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
ID      0       11:29:56.425    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
CO      0       11:29:56.597    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
MQ      0       11:29:56.957    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
MH      0       11:29:58.535    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
IS      0       11:29:58.566    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
EE      0       11:29:58.582    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
ML      0       11:29:58.629    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
DG      0       11:29:58.660    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
MI      0       11:29:59.347    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
KP      0       11:29:59.738    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
PJ      0       11:30:00.676    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
EM      0       11:30:00.691    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
RD      0       11:30:00.832    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
DN      0       11:30:00.832    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
NQ      0       11:30:00.832    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
PH      0       11:30:00.832    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14
LR      0       11:30:01.363    send_quotes (LKOH-9.14,H1)      no book was got on LKOH-9.14

То есть стакан по факту меняется, происходит вызов функции OnBookEvent, но MarketBookGet возвращает false?

Вопрос в том, что почему возвращается false и как это исправить?

Где-то 2 месяца назад запускал этот же код, всё работало. Теперь он понадобился сейчас - не работает.

Sergey Chalyshev
4903
Sergey Chalyshev  
У меня тоже перестало работать, написал в сервисдек.
Mikhail Filimonov
5931
Mikhail Filimonov  

Добрый день, beast!

Вы не правильно получаете данные!

Нужно в функции

void OnBookEvent(const string &symbol)
{
}

 Делать проверку, что в стакане именно вашего символа произошли изменения,

потому что как только вы добавили  if (!MarketBookAdd(SECURITY)), то получаете данные

по всем символам, которые у вас открыты!

Это подчёркнуто в хелпе. 

 if ( symbol == SECURITY)

void OnBookEvent( const string &a_symbol ) //TODO!!! Check to many set orders
{
  if ( a_symbol == SECURITY)
  {
    Вызываем функцию получкения стакана
    //--- Get stakan
    MqlBookInfo priceArray[];
    bool getBook = MarketBookGet( SECURITY, priceArray );
  }
Mikhail Filimonov
5931
Mikhail Filimonov  

И ещё...

Не используйте #define, а лучше переменную:

string my_symbol = "LKOH-9.14";
Mikhail Filimonov
5931
Mikhail Filimonov  

Проверил на новом билде 965 - ТОЖЕ НЕ РАБОТАЕТ!

Но что написано мною выше - правильно.

Sergey Chalyshev
4903
Sergey Chalyshev  
Для работы в текущем билде объявите два массива (среди глобальных переменных, использовать в программе не нужно)
   MqlRates    ExtRates[];
   MqlDateTime ExtDtime[];
Видимо в следующем билде будет исправлено.
Mikhail Filimonov
5931
Mikhail Filimonov  
Serj_Che:
Для работы в текущем билде объявите два массива (среди глобальных переменных, использовать в программе не нужно)
   MqlRates    ExtRates[];
   MqlDateTime ExtDtime[];
Видимо в следующем билде будет исправлено.

Привет!

Мне то же самое написали! :) 

Dennis Kirichenko
11490
Dennis Kirichenko  
Mikalas:

Привет!

Мне то же самое написали! :) 

И мне. И работает, что характерно :-)
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий