# Multiple currency comparison

183

I find the highest value and find the name of the pair by comparing the EMA.

What's the problem with the code below?

There is a warning to ‘ implicit ’ from ‘ number ’ to ‘ string ’.

Is there any kind of a function that can be found out from any pair?

``` int i;
int cnt, ticket, total;
bool ticketM;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
//---

//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---

}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
int start()
{
//---

double USD_EMA = GetEMA("EURUSD", 100);
double JPY_EMA = GetEMA("USDJPY", 100);

string Max_EMA = MathMax(USD_EMA,JPY_EMA);

total=OrdersTotal();
if(total<1)
{
if(GetEMA(Max_EMA, 100)>1)
{
if(ticket>0)
{

}
else
Print("Error opening BUY order : ",GetLastError());
return(0);
}
}

return(0);

}
//+------------------------------------------------------------------+

double GetEMA(string Sym_EMA, int EMA_PERIOD)
{

return( iMA(Sym_EMA, 0, EMA_PERIOD ,0,MODE_EMA, PRICE_MEDIAN,i));
}```
121

`string Max_EMA = MathMax(USD_EMA,JPY_EMA);`
It return a double value, not a string value, but you need a string (that is a name of currency pair) in this part, no?
16104

1. ```      double USD_EMA = GetEMA("EURUSD", 100);
double JPY_EMA = GetEMA("USDJPY", 100);```
Unless the chart is that specific pair/TF, you must handle 4066/4073 errors. See Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum
2. `      string Max_EMA = MathMax(USD_EMA,JPY_EMA);`
Naguisa Unada is correct. MathMax returns a double not a string. You could use
`    string Max_EMA = USD_EMA > JPY_EMA ? "EURUSD" : "USDJPY";`
but what's the point? EURUSD is a pair ranging 1.1-1.5. USDJPY is a pair ranging 74-124. The comparison will always be JPY.
3. ```   total=OrdersTotal();
if(total<1)```
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
4. `         ticket=OrderSend(Max_EMA,OP_BUY,1,Ask,3,0,0,"ma sample",1234,0,Green);`
This is why I recommend
Do not trade multiple currencies in one EA
5. You are not adjusting SL, TP, and slippage; for 4/5 digit brokers and for JPY pairs.