Problem with SymbolName (int pos, bool selected ) function. Symbol that is not in Market Window appears, althought selected bool true.

 

Hello,


I am in the process of creating the simple PIP calculator ( learning and portfolio purposes - I know a lot already exists ).

I have used CComboBox (MQL5 Standard Library. Panel And Dialogs) as the instrument selection field.

The part of the code responsible for displaying selected Symbols is following :


bool CMainMenu::CreateComboBox (void)
  {
   //--- coordinates
   int x1 = INDENT_LEFT ;
   int y1 = ( 3* INDENT_TOP) + ( 2 * EDIT_HEIGHT ) ;
   int x2 = x1 + LIST_WIDTH ;
   int y2 = y1 + LIST_HEIGHT ;
//--- create
   if(!m_combo_box.Create(m_chart_id,"ComboBox",m_subwin,x1,y1,x2,y2))
      return(false);  
   if(!Add(m_combo_box))
      return(false); 
//--- fill out with strings
   int NumberOfSymbols = SymbolsTotal ( true ) ;
   for(int i = 0  ; i < NumberOfSymbols - 1; i++)
      if(!m_combo_box.AddItem ( SymbolName ( i, true ) ) )
         return(false);      
//--- succeed
//    if(!ObjectSetString(0,"ComboBox",OBJPROP_TOOLTIP,"select symbol"))
//      return(false) ;
   return(true) ;         
  }


Unfortunately, there is something wrong.

SymbolsTotal(true), returns bigger symbols number value than is selected (13 instead 11) in the window. So I have more instruments in CComboBox Field displaying.

It looks folowing :


Symbols Total issue


I have got 11 instruments selected in Market Window, but there are appearing addictional 2 Symbols at CComboBox field  (USDPLN, EURPLN ) ...


Does anyone know where I am making a mistake ?

How to solve this problem ?

Documentation on MQL5: Market Info / SymbolSelect
Documentation on MQL5: Market Info / SymbolSelect
  • www.mql5.com
SymbolSelect - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Maybe you have open charts or pending orders or open positions for the added 2 symbols?
 
Amir Yacoby #:
Maybe you have open charts for the added 2 symbols?


SymbolsTotal Issue Full Screen

No, I have opened symbols only from Market List
 
Michal Herda #:

No, I have opened symbols only from Market List

Or pending orders / open positions?
 
Amir Yacoby #:
Or pending orders / open positions?


There are no pending orders and only one opened position on SP500


I have no idea what's wrong

 

Just as a trial I would try to close in code before the combo box creation

 bool open=SymbolSelect("USDPLN",false)&&SymbolSelect("EURPLN",false);
 
Also, are you running the Mql5 debugger? if so. on what chart does it run?
 
Amir Yacoby #:

Just as a trial I would try to close in code before the combo box creation


Unfortunately, this solution means that the selected instruments will not appear in the CCombobox window, even if they are on the market list.

At the moment it works, of course. But it seems to be temporary solution. 

Documentation says, that function in this form: 


SymbolName ( i, true ) ;


Should return only Symbols from marketwatch view....



MQL5 debugger is not running.


BTW I am sorry, I did not let know It is MQL4 working with MQL5 standard library.


I cannot edit topic title now .

 
Ok, I don't use MQL4 for long time now. Well, yes it's temporary, but you can remove that line now.

My guess (And I just confirmed it on MT5) is that some time before the previous run you opened USDPLN and EURPLN charts and than closed them - what leaves them in the market watch but does not show them on the market watch window. Bug or feature? Don't know 
 

Well, it turns out it's a feature..

There are symbols selected in market watch, but not visible.

So, if you want to see all of the symbols that your program selects, in the market watch, you need to use

SymbolInfoInteger - with SYMBOL_VISIBLE to be able to see them and set them to true in the process of adding them to combo.

Or - select to add to your combobox only those that are visible (SYMBOL_VISIBLE=true)

Visible

 
Amir Yacoby #:

Well, it turns out it's a feature..

There are symbols selected in market watch, but not visible.

So, if you want to see all of the symbols that your program selects, in the market watch, you need to use

SymbolInfoInteger - with SYMBOL_VISIBLE to be able to see them and set them to true in the process of adding them to combo.

Or - select to add to your combobox only those that are visible (SYMBOL_VISIBLE=true)



Thanks Amir :)

Reason: