Hi all,
How can write a function which converts a price in currency into an other currency ?
For exemple converting 38 EUR into AUD...
Is an mql5 function exists ?
Thanks,
Erwann.
For example, XXX to AUD
double price_aud = 38 * ExchangeRate("EUR"); //+------------------------------------------------------------------+ double ExchangeRate(string currency) //xxx to AUD { double ret_rate = -1.0; if (currency == "AUD") ret_rate = 1.00; else if (currency == "CAD") ret_rate = 1.00 / iClose("AUDCAD" + symbol_suffix, PERIOD_D1, 0); else if (currency == "CHF") ret_rate = 1.00 / iClose("AUDCHF" + symbol_suffix, PERIOD_D1, 0); else if (currency == "EUR") ret_rate = iClose("EURAUD" + symbol_suffix, PERIOD_D1, 0); else if (currency == "GBP") ret_rate = iClose("GBPAUD" + symbol_suffix, PERIOD_D1, 0); else if (currency == "JPY") ret_rate = 1.00 / iClose("AUDJPY" + symbol_suffix, PERIOD_D1, 0); else if (currency == "NZD") ret_rate = 1.00 / iClose("AUDNZD" + symbol_suffix, PERIOD_D1, 0); else if (currency == "USD") ret_rate = 1.00 / iClose("AUDUSD" + symbol_suffix, PERIOD_D1, 0); return (ret_rate); } //+-------------------------------------------------------------------+
There is no MT function to convert currencie rates, it has to be custom . Find out the path from input currency to output currency and multiply or divide by the appropriate rate, there should be no more than 3 steps .
Which is also incorrect. When you use a "reverse" symbol (so when you divide), you need to use the ask price. iClose() always returns the bid.
See https://www.mql5.com/en/forum/367457/page3#comment_21903583

TICK_VALUE for non account currency pair
- 2021.04.18
- www.mql5.com
I need to calculate tick value for currecy pair that does not include account currency, but getting different from defult SymbolInfoDouble(symbol...

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register