- Open a USD demo account with MQ or your broker and do your tests
- use points (pips) instead of money to speed up the tester:
- Open a USD demo account with MQ or your broker and do your tests
- use points (pips) instead of money to speed up the tester:
I don't want to open a USD demo account: I have a EUR account that works perfectly also if I choose to use USD as currency for my tests and optimizations, all the profits are perfectly calculated etc. The only thing is that, if I choose to use USD as currency for my optimization, the optimizer 'thinks' that the currency is always EUR. So I think this is a bug of MT5.
The tester in single mode correctly 'understands' that the currency is USD, only these functions of the optimizer are apparently not aware of this: OnTesterInit() and OnTesterDeinit(). Please try the code above to see what I mean.
I don't want to open a USD demo account: I have a EUR account that works perfectly also if I choose to use USD as currency for my tests and optimizations, all the profits are perfectly calculated etc. The only thing is that, if I choose to use USD as currency for my optimization, the optimizer 'thinks' that the currency is always EUR. So I think this is a bug of MT5.
The tester in single mode correctly 'understands' that the currency is USD, only these functions of the optimizer are apparently not aware of this: OnTesterInit() and OnTesterDeinit(). Please try the code above to see what I mean.
You are wrong as you are mixing Symbol and account currency. The account with its currency is needed for all the trade settings set by the broker and for a symbol you choose for trading you have this condition:
(See https://www.mql5.com/en/articles/1453)
So if you have e.g. a USD account the trading result of EURGBP is in GBP which has to be converted in USD of your account. Therefore the tester offers the calc. on pips or points to save the loading and converting the additional exchange rates.
- www.mql5.com
I think I found a bug, or at least a strange behavior, occurring when I choose to use in the Settings form of the Strategy Tester window a currency different from my account currency.
I have an EUR account, and if I choose to use USD as currency in the Strategy Tester, I see that this information is correctly propagated to my EA's OnInit() function but not to the OnTesterInit() event handler. It seems that the optimizer is not aware of this setting.
The following very simple code can be used to reproduce this behavior. If I perform a single execution of the EA, I can see that USD is correctly printed in the Journal, instead if a run an optimization, I see EUR printed.
input int fake_input = 1;
int OnInit()
{
Print("T Account currency: ", AccountInfoString(ACCOUNT_CURRENCY));
return INIT_FAILED;
}
int OnTesterInit()
{
Print("O Account currency: ", AccountInfoString(ACCOUNT_CURRENCY));
return INIT_FAILED;
}
void OnTesterDeinit()
{ }
As I said, I have an EUR account but would like to use USD currency to optimize all EAs operating on USD-based symbols, and would like to open a message box in the OnTesterInit() function if this condition is not met. At the moment, I cannot perform this check in the OnTesterInit() function.
The OnTesterInit() function and the likes are running on a live chart, not in the Tester. They are done to work with optimization passes results, there is no point to use AccountInfoxxx() functions there.
Yes, you're right because also AccountInfoDouble(ACCOUNT_BALANCE) for example returns different values in the OnInit() function (the deposit amount set in the Settings) and in the OnTesterInit() function (the real account balance).
This behavior appears strange to me because, at least from what I understand, the OnTesterInit() function is used for preparing an optimization, that is, multiple runs of the EA with different values for the inputs being optimized. These runs of the EA 'see' some account parameters (the 'fake' ones, set in the Setting and being simulated as parameters of a fake account), the OnTesterInit() function, immediately before starting optimization, 'sees' other account parameters (the ones of the real account).
Is there any other way to retrieve the deposit currency set in the Settings before optimization starts?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I think I found a bug, or at least a strange behavior, occurring when I choose to use in the Settings form of the Strategy Tester window a currency different from my account currency.
I have an EUR account, and if I choose to use USD as currency in the Strategy Tester, I see that this information is correctly propagated to my EA's OnInit() function but not to the OnTesterInit() event handler. It seems that the optimizer is not aware of this setting.
The following very simple code can be used to reproduce this behavior. If I perform a single execution of the EA, I can see that USD is correctly printed in the Journal, instead if a run an optimization, I see EUR printed.
input int fake_input = 1;
int OnInit()
{
Print("T Account currency: ", AccountInfoString(ACCOUNT_CURRENCY));
return INIT_FAILED;
}
int OnTesterInit()
{
Print("O Account currency: ", AccountInfoString(ACCOUNT_CURRENCY));
return INIT_FAILED;
}
void OnTesterDeinit()
{ }
As I said, I have an EUR account but would like to use USD currency to optimize all EAs operating on USD-based symbols, and would like to open a message box in the OnTesterInit() function if this condition is not met. At the moment, I cannot perform this check in the OnTesterInit() function.