How to handle this Different Order Symbols

 

Hello,

i have write a trade copy tool and i have a question, when i have a Order in EURUSD and i want to open in the Metatrader where i receive this signal also a Order in EURUSD, but this Broker have another name for EURUSD, how can i codeing it to open in EURUSD a order?


if i make this:

OrderSend(EURUSD,OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);


then that does not work when the Broker have other name like "FxEURUSD" for the symbol, but how can a make here a code that can see this difference and open then in FxEURUSD the order?

 
PlanandTrade:

Hello,

i have write a trade copy tool and i have a question, when i have a Order in EURUSD and i want to open in the Metatrader where i receive this signal also a Order in EURUSD, but this Broker have another name for EURUSD, how can i codeing it to open in EURUSD a order?

Compare the symbol in the signal to the symbol of the chart by manipulating the strings,  if your signal has "EURUSD" check if Symbol() contains "EURUSD" using StringFind()  if it does then place the trade on the current symbol.  If you want to place the trade on a symbol other than the chart symbol you will have to manipulate EURUSD into "FxEURUSD"
 
RaptorUK:
Compare the symbol in the signal to the symbol of the chart by manipulating the strings,  if your signal has "EURUSD" check if Symbol() contains "EURUSD" using StringFind()  if it does then place the trade on the current symbol.  If you want to place the trade on a symbol other than the chart symbol you will have to manipulate EURUSD into "FxEURUSD"


but the problem is i have no list from the symbol names that the current broker use.

if i would have a list from symbols that the broker use, then i could look in wich symbol name is EURUSD into, but there is no list or function that i can call wich show me all symbol names from the current broker.

 
PlanandTrade:

but the problem is i have no list from the symbol names that the current broker use.

if i would have a list from symbols that the broker use, then i could look in wich symbol name is EURUSD into, but there is no list or function that i can call wich show me all symbol names from the current broker.

There is a list . . .  check out this code:  https://www.mql5.com/en/code
 
and based on that I previously wrote:
int      FindSymbols(string& symbols[]){     // Get list of all tradeable pairs.
   #define FNAME "symbols.raw"
   int      handle=FileOpenHistory(FNAME, FILE_BIN | FILE_READ);
   if(handle<1){                                               DisableTrading(
      "Unable to open file"+FNAME+", error: "+GetLastError());    return(0);  }
   #define  RAW_RECORD_SIZE   1936
   #define  RAW_SYMBOL_SIZE   12
// #define  RAW_DESCR_SIZE    75
      #define  RAW_SKIP_DESCR    1924  // 1936-12
//    #define  RAW_SKIP_REMAN    1849  // 1936-12-75
   int      nRecords=FileSize(handle) / RAW_RECORD_SIZE;
   if(ArrayResize(symbols, nRecords) <= 0){                    DisableTrading(
      "ArrayResize(Symbols, "+nRecords+") Failed: " + GetLastError() );
      FileClose(handle);                                          return(0);  }
   for(int iRec=0; iRec < nRecords; iRec++){
      // "AUDCAD<NUL><NUL><NUL><NUL><NUL><NUL>"
      symbols[iRec]  = FileReadString(handle, RAW_SYMBOL_SIZE);
      FileSeek(handle, RAW_SKIP_DESCR, SEEK_CUR);     // goto the next record
      // "Auzzie Dollar  vs. Canadian Dollar<NUL><NUL><NUL>..."
      // dsc[nRec]   = FileReadString(handle, 75);
      // FileSeek(handle, RAW_SKIP_REMAN, SEEK_CUR);  // goto the next record
   }
   FileClose(handle);
   return(nRecords);
}  // FindSymbols
string   symbol.prefix, symbol.infix, symbol.postfix; // Export to symbolCross.
int      iSymbol.base,  iSymbol.quote;                // Export to ComputeRCS.
void OnInitCurrencies(){
   string   brokerSymbols[];  int nSymbols = FindSymbols(brokerSymbols);
                              if (nSymbols <= 0)                        return;
   //{ isolate prefix, infix, and postfix extra characters and base/quote
   // Broker's use a variety of nameing patterns: EURUSD, EURUSDm, "EURUSD.",
   // "EURUSD..", "EURUSD#",  "EUR.USD", "EUR/USD", "EURUSD.stp", "EURUSDct".
   #define iPREFIX 0
   int      iBase = iPREFIX - 1;
   for(int iPair = 0; true; iPair = (iPair+1) % nSymbols){
      if(      iPair == 0){   iBase++;
         int   testChar = StringGetChar(brokerSymbols[iPair], iBase);         }
      else  if(testChar != StringGetChar(brokerSymbols[iPair], iBase))  break;
   }
   int      iInfix = iBase + 3, iQuote = iInfix - 1;
   for(iPair = 0; true; iPair = (iPair+1) % nSymbols){
      if(      iPair == 0){   iQuote++;
               testChar = StringGetChar(brokerSymbols[iPair], iQuote);        }
      else  if(testChar != StringGetChar(brokerSymbols[iPair], iQuote)) break;
   }
   //init(): string market.pair    = Symbol();
   int   iPosfix  = iQuote + 3,  nChar = StringLen(market.pair);
   symbol.prefix  = ""; if(iBase  > iPREFIX) // count=0 treated as ALL!
   symbol.prefix  = StringSubstr(market.pair, iPREFIX, iBase  - iPREFIX);
   symbol.infix   = ""; if(iQuote > iInfix)
   symbol.infix   = StringSubstr(market.pair, iInfix,  iQuote - iInfix);
   symbol.postfix = ""; if(nChar  > iPosfix)
   symbol.postfix = StringSubstr(market.pair, iPosfix, nChar  - iPosfix);
   //} isolate prefix, infix, and postfix extra characters and base/quote
:
Reason: