Download MetaTrader 5

how to check automatically for any suffixes added to symbols in market watch, so indicator work on all broker's account type's ?

To add comments, please log in or register
Mehrdad Shiri
4512
Mehrdad Shiri  

hi;

in my multi currency indicator in default ;

for example symbol " EURUSD"  i check/add in market watch ,so indicator calculate & draw.

my question is: if some broker/account type use another symbol like " EURUSD.m " or any other suffixes added to EURUSD or " eurusd " ....

  or     ( is there another ? )

( in calculation those are all equal together ) , how can do this automatically without any modify from user with change from indicator's Input.

thank's in advance.
Rogerio Figurelli
Moderator
40336
Rogerio Figurelli  
TIMisthebest:

hi;

in my multi currency indicator in default ;

for example symbol " EURUSD"  i check/add in market watch ,so indicator calculate & draw.

my question is: if some broker/account type use another symbol like " EURUSD.m " or any other suffixes added to EURUSD or " eurusd " ....

  or     ( is there another ? )

( in calculation those are all equal together ) , how can do this automatically without any modify from user with change from indicator's Input.

thank's in advance.

As far as I know there is no automatically way or ready function to do that. 

Anyway, in trading signals copying there is something similar that the MQ team could use to create such public function.

Anton Nel
37688
Anton Nel  
Need to write your own function to handle this.
Mehrdad Shiri
4512
Mehrdad Shiri  

thank you.

i used bellow in my code.( fore example for "EURUSD" )

string SYMBOLS_NAMES[1]="EURUSD" // must check for other type & any other suffixes added { eurusd EURUSD.m ...}
.
.
.
//-----------------------
void OnInit()
  {
   InitSymbolNames(); //--- Initialize the array of symbols
.
.
.
   
  }
//-----------------------
int OnCalculate(const int rates_total,const int prev_calculated,
                const datetime &Time[],
                const double   &Open[],
                const double   &High[],
                const double   &Low[],
                const double   &Close[],
                const long     &TickVolume[],
                const long     &Volume[],
                const int      &Spread[])
{
 InitSymbolNames();
.
.
.
 return(rates_total);
}
//-----------------------
void InitSymbolNames()
  {
   AddSymbolToMarketWatch(SYMBOLS_NAMES[1]);
  }
//+++
//+------------------------------------------------------------------+
string AddSymbolToMarketWatch(string symbol)
  {
   int      total=0; // Number of symbols
   string   name=""; // Symbol name
   //--- If an empty string is passed, return the empty string
   if(symbol=="")
      return(empty_symbol);
//--- Total symbols on the server
   total=SymbolsTotal(false);
//--- Iterate over the entire list of symbols
   for(int i=0;i<total;i++)
     {
      //--- Symbol name on the server
      name=SymbolName(i,false);
      //--- If this symbol is available,
      if(name==symbol)
        {
         //--- add it to the Market Watch window and
         SymbolSelect(name,true);
         //--- return its name
         return(name);
        }
     }
//--- If this symbol is not available, return the string representing the lack of the symbol
   return(empty_symbol);
  }
//****

any help to continue.

thank's.

Anton Nel
37688
Anton Nel  

Problem if you have...

if(name==symbol)

name = "EURUSD.m"

symbol = "EURUSD" 

Mehrdad Shiri
4512
Mehrdad Shiri  
ROMAN5:

Problem if you have...

name = "EURUSD.m"

symbol = "EURUSD" 

yes i have Bewildered about this and it's Relationship with " add to market watch ".
Jian Chen
Moderator
3650
Jian Chen  

So you need to modify the "name==symbol" code as below:

 

if(StringCompare(StringSubstr(name, 0, 6), StringSubstr(symbol, 0, 6), false)==0)
Anton Nel
37688
Anton Nel  
forex2start:

So you need to modify the "name==symbol" code as below:

 

// MODE_MARGINCALCMODE: 0 - Forex; 1 - CFD; 2 - Futures; 3 - CFD for indices

if (MarketInfo(name,MODE_MARGINCALCMODE) == 0 &&
    StringCompare(StringSubstr(name, 0, 6), StringSubstr(symbol, 0, 6), false) == 0)
length = 6 for Forex (mostly).
Mehrdad Shiri
4512
Mehrdad Shiri  

forex2start:

ROMAN5:

thank you.

in my code, if symbol is not exist in market watch , it will be add and use, ( automatically )

#define SYMBOLS_COUNT   29 // Number of SYMBOLS "1+28"
string SYMBOLS_NAMES[SYMBOLS_COUNT]={"EMPTY","EURGBP","EURAUD","EURNZD","EURUSD","EURCAD","EURCHF","EURJPY"
//                                      0       1        2        3        4        5        6       7
                                    ,"GBPAUD","GBPNZD","GBPUSD","GBPCAD","GBPCHF","GBPJPY"
//                                      8        9       10       11        12       13
                                    ,"AUDNZD","AUDUSD","AUDCAD","AUDCHF","AUDJPY"
//                                      14      15        16       17      18
                                    ,"NZDUSD","NZDCAD","NZDCHF","NZDJPY"
//                                      19      20       21        22
                                    ,"USDCAD","USDCHF","USDJPY"
//                                      23       24       25
                                    ,"CADCHF","CADJPY"
//                                      26       27
                                    ,"CHFJPY"                              
//                                      28
                           };

i think in your solution, at first ; must add all forex symbol and then use " SYMBOL_SELECT " and get equal's for symbol and compar them.

is i am right ?

if yes, so how can insert our symbol's automatically in market watch?

thank you all.

Anton Nel
37688
Anton Nel  
void InitSymbolNames()
{
   for(int i=0;i<SYMBOLS_COUNT;i++)
   {
      AddSymbolToMarketWatch(SYMBOLS_NAMES[i]);
   }
}
Mehrdad Shiri
4512
Mehrdad Shiri  
ROMAN5:
length = 6 for Forex (mostly).

thank you;

sorry, i will try.

// MODE_MARGINCALCMODE: 0 - Forex; 1 - CFD; 2 - Futures; 3 - CFD for indices
12
To add comments, please log in or register