a way to calculate the "base currency" of the Symbol on MQL5

To add comments, please log in or register
patagonia2015
120
patagonia2015  

I want to know what base currency of the Symbol.

I need this because depending of the base currency I will use a Risk % per trade. My broker have stocks from UK, US and EUR. Each one of this is in different currency and my money function always is considering my account currency (USD), so is not exactly the % I want to risk.


Is there a function to do this? I have look but not found anything. Please help.

Anthony Garot
2581
Anthony Garot  
patagonia2015:

I want to know what base currency of the Symbol.

const string base = StringSubstr(symbol,0,3);
const string quote = StringSubstr(symbol,3);
patagonia2015
120
patagonia2015  
Anthony Garot:
Thank you. I checked that, but for some reason is not working in my code. For example I want to check if the last 4 strings of the symbol are "UK-d" and it doesn't work.
lippmaje
371
lippmaje  

This might work:

string currency=SymbolInfoString(_Symbol,SYMBOL_CURRENCY_BASE);
lippmaje
371
lippmaje  

patagonia2015:

I don't know what is wrong. My broker have FX, futures and Stocks from UK, EUR and US. And I want a risk per trade calculation for everything. This is the part of the code that is giving me trouble. "PorcentajeRiesgo" variable is a input of course.

Type of 'PorcentajeRiesgo'?
patagonia2015
120
patagonia2015  
lippmaje:
Type of 'PorcentajeRiesgo'?
Is embarrassing to say but I didn't know and maybe help someone else. The code works, I was using my expert and the money management is a #include file. I was just compiling the include file and not the expert. Seems that make the code work as intended. Thank you for the help guys!
To add comments, please log in or register