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

 
TIMisthebest:

thank you;

sorry, i will try.

Change from

if(name==symbol)

 to

// 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)
 
ROMAN5:

Change from

 to

thank's to all.

i will try and comment it here.( completed code)

 

what is wrong?

.
.
.
int total_symbol=0; // Number of symbols name on the server
string empty_symbol="EMPTY";
string SYMBOLS_NAMES[SYMBOLS_COUNT];
.
.
.
//*************************************************************************
void OnInit()
  {
   SYMBOLS_NAMES[0]="EMPTY";
   InitSymbolNames();
.
.
.
}
//+------------------------------------------------------------------+
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();
.
.
.
//--- done
   return(rates_total);
}
//+------------------------------------------------------------------+
void InitSymbolNames()
  {
   AddSymbolToMarketWatch(SYMBOLS_NAMES[1],"EUR","eur","GBP","gbp");
  }
//+------------------------------------------------------------------+
string AddSymbolToMarketWatch(string name,string PART_1,string part_1,string PART_2,string part_2)
  {
   name=empty_symbol;                // Symbol name
   total_symbol=SymbolsTotal(false);          //--- Total symbols on the server
//--- Iterate over the entire list of symbols
   for(int i=0;i<total_symbol;i++)
     {      
      if(
         (SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_BASE)==PART_1&&SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_PROFIT)==PART_2)
         ||
         (SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_BASE)==part_1&&SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_PROFIT)==part_2)
        )
        {
         name=SymbolName(i,false);  //--- If this symbol is available,
         SymbolSelect(name,true);   //--- add it to the Market Watch window and
         return(name);              //--- return its name
         break;
        }
     }
   return(name);
  }
//********************************************************************************************************************
thanks in advance.
 

Hi, I just tested your code on my computer and it works. In two of my accounts, The "EURGBP" and "EURGBP.m" symbols can be added to my market watch window after I attached the indicator.

However, there is a little problem in your code, you can not get the symbol's name in the SYMBOLS_NAMES[] array.

You should use reference type in the first parameter of "AddSymbolToMarketWatch" function:

string AddSymbolToMarketWatch(string & name,string PART_1,string part_1,string PART_2,string part_2)


 

 
forex2start:

Hi, I just tested your code on my computer and it works. In two of my accounts, The "EURGBP" and "EURGBP.m" symbols can be added to my market watch window after I attached the indicator.

However, there is a little problem in your code, you can not get the symbol's name in the SYMBOLS_NAMES[] array.

You should use reference type in the first parameter of "AddSymbolToMarketWatch" function:

thank you.
 

hi can i have indicator ?

thanks

 

how do I add the indicator? save txt posted as a mq5 or ex5 file then open in MT5?

 
 string symbol_suffix(){
 string ky ="";
 if(StringLen(Symbol())>6){    //covers gold and other symbol
 if(StringSubstr(_Symbol,0,StringLen(Symbol()))!= StringSubstr(_Symbol,0,6)) ky = StringSubstr(_Symbol,6,0);
 

    }
     return(ky);
 }      

this is for  in case someone need to get symbol suffix

 
Gbenga Ayodele:

this is for  in case someone need to get symbol suffix

How do you handle BRENT and WTI?

 
string suffix = StringSubstr(Symbol(),StringFind(Symbol(),".",0),StringLen(Symbol()));
  Alert(suffix);
Reason: