I have seen some brokers incorrectly setting the demo / real flags. Not a lot you can do about it other than
1. Speak to your broker
2. Change servers (if possible)
3. Change brokers
Makes life hard when you're trying to limit the usage of your EA.
Out of interest, what does this show?
long trade_mode = AccountInfoInteger(ACCOUNT_TRADE_MODE); Comment(EnumToString((ENUM_ACCOUNT_TRADE_MODE)trade_mode));
I have seen some brokers incorrectly setting the demo / real flags. Not a lot you can do about it other than
1. Speak to your broker
2. Change servers (if possible)
3. Change brokers
Makes life hard when you're trying to limit the usage of your EA.
Out of interest, what does this show?
Thanks for you time,
That returns : ACCOUNT_TRADE_MODE_REAL
Thanks for you time,
That returns : ACCOUNT_TRADE_MODE_REAL
This is also problem with the MQL4, try this code ( indicator ):
int OnInit(){ if (IsDemo()) Print("DEMO: ",UninitializeReason()," ",AccountInfoInteger(ACCOUNT_TRADE_MODE)," == ",ACCOUNT_TRADE_MODE_REAL); else Print("NO DEMO: ",UninitializeReason()," ",AccountInfoInteger(ACCOUNT_TRADE_MODE)," == ",ACCOUNT_TRADE_MODE_REAL); return INIT_FAILED; } void OnTick(){;} int OnDeinit(int reason){ Print("Reason: ",reason);return reason;}
get 2 different output.
first if the indicator attached in a chart. But if restarted platform MT4, IsDemo function return false
Milan
int OnInit(){ if (IsDemo())Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Thank's,
you are true, save for me many hours ...
Could anyone assist me with the issue below please ?
We are creating an EA and trying to set it for free on a demo server and so i chose "true" for ISDEMO(), but when we run the expert on my broker demo server, it turns into "false" and asks for a license key.
Your assistance would be greatly appreciated.
Thanks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Please, could you help me ?
void OnTick()
{
Comment(IsDemo());
That returns "False" with my demo account