Subscription to OnBookEvent sometimes falls off - is there such a thing? - page 4

 
Stanislav Korotky:

By the way, all other types of events are broadcast events, only they don't need to be connected or disconnected - everything is communicated automatically during script initialization.

OnChartEvent has broadcasting events - as well as normal events.

And if you could do the normal ones there - you can do them here too

 
A100:

Not at all - OnChartEvent receives broadcast events - as well as normal events

And if you can do broadcasts there, you can do broadcasts here too.

And what about other events OnTick or OnCalculate? Any objections to their broadcasting? OnChartEvent is also broadcast, despite the add-ons. If the objection is to the word "all", I'll replace it with "many". The point is that all options so far have ruled out the possibility of someone else's disabling it.

We'll see if there is a correction.

 
prostotrader:

Good news.

Which error is that about? I see the exact same post about the disabled transaction.

 
prostotrader:

Your subscription is failing because of aninvalid book transaction error

It fails because of an indirect MarketBookRelease call - odd that you haven't figured that out by now
 
prostotrader:
I don't callMarketBookRelease but wheninvalid book transactionappears in the log

OnBookEvent stops dialling (you could say the subscription "falls off")

This is a completely different cause of the error than the one discussed in this thread. If you eliminate one cause, the other will not disappear by itself

Just like here https://www.mql5.com/ru/forum/1111/page2237#comment_8159123 the errors were the same in form but the way of fixing one did not fit the other - so the reasons are different

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2018.07.23
  • www.mql5.com
Общее обсуждение: Ошибки, баги, вопросы
 
prostotrader:

I'm sure this is the reason for the bug.

The developers have fixed it and when the new build comes out, we will check "your" error then.

The test example is simple: call MarketBookAdd( x ) in the 1st Expert Advisor, then call MarketBookRelease( x ) in the 2nd Expert Advisor... and then wait for OnBookEvent( x ) event in the 1st Expert
 
A100:
Checking example is simple: call in 1st EA MarketBookAdd( x ), then call in 2nd MarketBookRelease( x )... And wait for 1 event

If you do what you write on the same symbol, Naturally the subscription will be destroyed by that symbol in the same terminal!

And this is correct.

Added by

You just need to use the subscription correctly.

//+------------------------------------------------------------------+
//|                                                        Books.mq5 |
//|                                      Copyright 2018 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
bool is_book;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
    is_book = false;
//--- Add books
    if(!MarketBookAdd(Symbol()))
    {
      MessageBox("Не добавлен стакан фьючерса!", "Ошибка", MB_OK | MB_ICONHAND);
      return(INIT_FAILED);
    } 
    else is_book = true;
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
    if(is_book = true) MarketBookRelease(Symbol());
   
  }

//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
  {
   if(symbol == Symbol())
   {
     //Plece you code here
   }
   
  }
//+------------------------------------------------------------------+
 
prostotrader:

If you do what you write on the same symbol, Naturally the subscription will be destroyed by that symbol in the same terminal!

And this is correct.

Then do the following: call MarketBookAdd( x ) in 1st EA, then call MarketBookAdd( x ) and MarketBookRelease( x ) in 2nd EA... and then wait for OnBookEvent( x ) event in the 1st Expert
 
A100:
Then do the following: call MarketBookAdd( x ) in the 1st Expert, then call MarketBookAdd( x ) and MarketBookRelease( x ) in the 2nd Expert... and then wait for OnBookEvent( x ) event in the 1st Expert

Use my code and you won't have problems with subscription.

 
prostotrader:

Use my code and you won't have a problem subscribing.

Tomorrow I'll check the magic power of your code... in the meantime I'd like your opinion on can the function of opening/closing a glass be combined with the function of subscription/unsubscription to/from events on this glass or should they be separated
Reason: