Hello, dear colleagues! Faced with the problem of adding a large number of characters to MarketWatch. I use the symbolselect () function, the code is:
// get the number of all the broker's instruments
SymbsTotal = SymbolsTotal(false);
//setting the size of the array for tools
ArrayResize(SymbolBuff,SymbsTotal);
//Fill the array with the names of the instuments in the loop
for( int i=0; iSymbolName(i, false);
//Adding a symbol to MarketWatch
SymbolSelect( SymbolBuff[i], true);
} And everything seems to be fine, the code works, but when you add a large number of tools, the Metatrader hangs for dozens of minutes, does not respond to any clicks at all, just freezes. My broker has 4000+ instruments and I want to track certain trading conditions for all of them. The situation would seem to be cheap, you can just turn on the display of all simols in the terminal yourself, but there may be two “Buts”. The first situation is if I suddenly turn off a tool or a group of tools, forgetting that I need to display everything, or I give someone a robot and it turns off the display of symbols in MarketWatch, the expert will simply not receive information on the disabled pairs and, accordingly, will not monitor the situation for entry. are there any other functions or ways to solve this problem how to display all symbols programmatically without hanging the metatrader?
viktorternovskiy
In general, after a few days of dancing with a tambourine, I implemented adding one missing symbol per second. And it does not hang and gradually adds everything. If you forget and delete the desired symbol by accident, then everything will be restored within a maximum of a few minutes. So I think it’s not critical.
alexeyvik
Why do you invent a bicycle with wheels across? That’s exactly the kind of design that doesn’t work.
if(!symbolinfointeger(symbolbuff[i], SYMBOL_VISIBLE))
Or your option
if ( SymbolInfoInteger(SymbolBuff[i], SYMBOL_VISIBLE) == false)
I can not explain the reason, but I came to this after repeated experiments and misunderstanding of what is happening. Take the entire check block and enter the check and delete instead of the line ” / / and here………” if there is such a need. Or just a message that the symbol is not added.
viktorternovskiy
Because my broker has more than 4000 + tools and when you close them all (just press a couple of keys, it’s not difficult), adding them programmatically then hangs the metatrader completely for several tens of minutes. Okay, I also, I understand the algorithm and know what can happen and what to do. But if I then distribute this Expert Advisor, then an inexperienced user may not read or forget about such a feature that you can not hide symbols from MarketWatch, otherwise the Metatrader may hang. In short, an embarrassment can come out and a person will think that this robot is crooked, since because of it there are such lags.
alexeyvik
Or maybe you should first check the presence of the symbol in the market review
SymbolInfoInteger(SymbolBuff[i], SYMBOL_SELECT);
SymbolInfoInteger(SymbolBuff[i], SYMBOL_VISIBLE);
and only then insert?
viktorternovskiy
Well, since the situation is complicated, then after thinking about splitting and queuing and understanding that this is also not an ideal option, such an idea came up, why not just check for the presence of the tool and if it is not in MarketWatch, then instead of trying to add it, just issue a notification to the user. having checked such an algorithm even with only a couple of tools included in the market review, all the other 4000+ turned off the algorithm managed in a fraction of a second. Here is a line of code:
// Checking a symbol in MarketWatch in a loop
if ( SymbolInfoDouble(symbolbuff[i], SYMBOL_BID) = 0) Alert("Turn on the display of all symbols in MarketWatch, Clumsy!!!");
nektomk
symbolselect does not always succeed immediately 🙁 and the result strongly depends on the DC and the visible type of the account (the Demo is rarely played on MetaQuotes). I’ve been fighting it myself for a few days
it is necessary to repeat with expectations and in several attempts, while giving control back to MT (that is, exit onTick/OnTimer). That is, you need to make a queue, enter symbols for Watch there, and periodically select from it and try to use symbolselect