Questions from Beginners MQL5 MT5 MetaTrader 5 - page 370

 
Vitalii Ananev:

Here is a piece of code where this function is used. In this example, symbols specified by user (Symbols array) are included in "Market Watch" window. If there is no such symbol, the appropriate message is displayed. Do not be lazy to read the help for this function, it is clearly written there.

P.S.

In order for the Expert Advisor (indicator) to work correctly with any symbols, they should be enabled in the "Market Watch" window, this function is just for this purpose.

Yeah, I got it. I will correct it for my robot. I will do it. If you have any questions, I will write them here. Thank you from the bottom of my heart.
 
Roman Shiredchenko:
Yep, got it. for the robot - I'll fix it. I will do it. If I have any questions, I will write it here. Thank you from the bottom of my heart.

It all depends on the requirements and needs of the program. Here's also a piece of code in OnInit(), which prepares the required symbols and graphs depending on EA settings.

   
   //--- подготавливаем рабочие графики
   // "EURUSD,GBPUSD,GBPCHF,CADCHF,AUDCAD,AUDUSD,AUDNZD,NZDUSD,CHFJPY,USDCAD,USDCHF,USDJPY" список
   //symbolsInMW=0,  // Все символы                 selectedSymbol=false
   //symbolsInMW=1,  // Только в обзоре рынка       selectedSymbol=true
   //symbolsInMW=2,  // Все открытые графики        selectedSymbol=true
   //symbolsInMW=3,  // Список торгуемых символов   selectedSymbol=false
   //symbolsInMW=4,  // Текущий график с советником selectedSymbol=true

   selectedSymbol=(symbolsInMW==0 || symbolsInMW==3)?false:true;
   totalSymbols=SymbolsTotal(selectedSymbol);               // Достаточное количество символов
   if(symbolsInMW!=4) {                                     // Если работаем в мультивалютном режиме
      for(int i=0; i<totalSymbols; i++) {                   // цикл по списку символов (либо в обзоре рынка, либо по всем)
         string symbol_name=SymbolName(i,selectedSymbol);   // наименование символа
         chart_id=get.GetChartID(symbol_name);              // найдём ID графика
         //--- график выбранного символа не открыт
         if(symbolsInMW==3 && StringFind(ListOfSymbols,symbol_name)<0) continue; // если работаем со списком и символа в списке нет - идём дальше
         if(chart_id<0 && symbolsInMW!=2) {                 // если графика нету и не выбрана работа только с открытыми графиками
            if(symbolsInMW==0 && !SymbolInfoInteger(symbol_name,SYMBOL_SELECT))  // если работаем со всеми символами и символ не выбран ...,
               SymbolSelect(symbol_name,true);              // ... выберем символ в обзоре рынка
            chart_id=ChartOpen(symbol_name,PERIOD_H4);      // откроем график символа
            }
         //--- график выбранного символа уже открыт
         if(chart_id>=0) {
            if(symbol_name!=symbol) {                                         // если выбранный символ не символ текущего графика
               graph.Message("Load template \"Agent.tpl\" on "+symbol_name);
               ResetLastError();
               if(ChartApplyTemplate(chart_id,"Agent.tpl")) {                 // если загрузили шаблон - закинем подложку
                  ChartSetInteger(chart_id,CHART_BRING_TO_TOP,true);          // График поверх других
                  SetCanvas(symbol_name,chart_width,0,0,0);
                  }
               //--- иначе - сообщение с ошибкой
               else graph.Message("Failed to load the template \"Agent.tpl\" on chart "+symbol_name+", error "+IntegerToString(GetLastError()));
               }
            }
         }
      }
   SetCanvas(symbol,chart_width,0,0,0);   // Подложка основного графика с советником (здесь шаблон не нужен)

Well, here you can only look at the principle. Maybe it will help ;)

 
Artyom Trishkin:

It all depends on the requirements and needs of the program. Here is also a piece of code in OnInit(), which prepares the required symbols and graphs depending on the EA settings.

Well, here you can only look at the principle. Maybe it will help ;)

Artem - in a private message. Look. Plz.
 
Roman Shiredchenko:
Artem - I've written to you in person. Check it out. Plz.
I will, but no new messages in my inbox yet
 
Roman Shiredchenko:
Artem - I've written to you in person. Check it out. Plz.

Looked again - nothing...

I got to leave in 15 minutes. Hurry up ;)

 
Artyom Trishkin:

Looked again - nothing...

I have to leave in 15 minutes. Hurry up ;)

can't write - how - I don't have that option there...

help....

 
Roman Shiredchenko:

I can't write how - I don't have that option there...

help....

You click on my name -- go to my profile -- there's a "Write a message" button at the top right.

Although ... I already wrote it myself -- answer it.

 
Artyom Trishkin:

You click on my name -- go to my profile -- there's a button at the top right that says "Write a message".

Although... I already wrote it myself -- answer it.

You got it. OKAY. You got it.
 
Roman Shiredchenko:

I can't write how - I don't have that option there...

help....

 
Vitalie Postolache:

Oh man... It's about damn time.

Yeah, well... and I was dumb enough to send him a message in a private message.

Oh, well... It's been written, read, and eaten.

Reason: