OrderSend Error 4109 - Trade is not allowed.

 

Hi there,


I manage a number of VPS's with EA's installed on them using. All using the same EA. I come across a problem where some of the EA's will give a 4109 error when trying to open trades. This does not make sense to me as I have allowed live trading in the options and the EA settings, I have AutoTrading on, and I am 100% confident that from an MT4 settings perspective everything should work fine.

I have also contact the brokers where I find this error, and all of them claim it is due to the settings on the MT4 platform. This also does not make sense as all the VPS's I run use the same image, and the same settings for MT4. Most are able to trade without any problems, but some have this issue.


The only thing that I can think of is that I have 2 charts running. On chart 1, I have the actual trading EA. On chart 2, I have another EA, which monitors the activity of chart 1, and if the EA has stopped working, it applies a template to reload the EA on chart 1. This is a fail safe to ensure that i have EA 1 loaded 24/7. This same setup is applied across all MT4's / all VPS's. Is it possible that there is something in the privileges of applying this template that would prevent live trading even if all settings are correct?


Other than this possibility I am completely stumped as to why I would get a 4109 error on some accounts and not others.


Any thoughts or advice would be highly appreciated!

 

Live trading and DLL imports permissions cannot be extended for the Expert Advisors launched by applying the template using ChartApplyTemplate() function.

If the mql4 program calling ChartApplyTemplate() function has no permission to trade, the Expert Advisor launched via the template will also not be able to trade regardless of the template settings.

If the mql4 program calling ChartApplyTemplate() function has permission to trade, while there is no such permission in the template settings, the Expert Advisor launched via the template will not be able to trade.

ChartApplyTemplate - Chart Operations - MQL4 Reference
ChartApplyTemplate - Chart Operations - MQL4 Reference
  • docs.mql4.com
ChartApplyTemplate - Chart Operations - MQL4 Reference
 

Thanks Alain!


So calling ChartApplyTemplate() from a different EA is going to cause a problem then. This should not be the case if I call the function from the EA I want to trade correct? 

 
Richard Read:

Thanks Alain!


So calling ChartApplyTemplate() from a different EA is going to cause a problem then. This should not be the case if I call the function from the EA I want to trade correct? 

It should not be a problem is you call ChartApplyTemplate() from an EA which has trading privileges AND your template has trading privileges enabled.
 
Alain Verleyen:
It should not be a problem is you call ChartApplyTemplate() from an EA which has trading privileges AND your template has trading privileges enabled.


Hmm yea its strange, The trading EA creates the template (so it should therefore have privileges), and the EA applying the template also as trading privileges. So it doesn't make sense why I would still get a 4109.


Any way to check if a template has trading rights?

 
Richard Read:


Hmm yea its strange, The trading EA creates the template (so it should therefore have privileges), and the EA applying the template also as trading privileges. So it doesn't make sense why I would still get a 4109.


Any way to check if a template has trading rights?

Apply your template to an empty chart and see if the EA has live trading enabled.
 

Error 4109 because you not enable AutoTrading.

Before apply template file, you must enable AutoTrading, if not, your EA will not "Allow Live Trading".

 
Alain Verleyen:
Apply your template to an empty chart and see if the EA has live trading enabled.

Yes it does, smiley face, and allow live trading in EA & MT4 settings. So It seems the template does have trading privileges, guess I am back to the drawing board as to why it gives 4109 errors on some accounts.
 
Richard Read:

Yes it does, smiley face, and allow live trading in EA & MT4 settings. So It seems the template does have trading privileges, guess I am back to the drawing board as to why it gives 4109 errors on some accounts.

More than 1 year after you, I got the same issue, but from time to time only, kind of randomly as up to now I didn't found any logic.

Global "Automatic trading" IS enabled. The "Main" EA applying templates to other charts HAS "Live trading" enabled, and of course also the template as correct flags.

The templates are applied every days, and sometimes one day, you got error 4109 on an EA launched with a template. On the "Main" EA there is a button to apply the templates manually, and when you do it, all is back to normal...until next time it will happen.

 
Alain Verleyen:

More than 1 year after you, I got the same issue, but from time to time only, kind of randomly as up to now I didn't found any logic.

Global "Automatic trading" IS enabled. The "Main" EA applying templates to other charts HAS "Live trading" enabled, and of course also the template as correct flags.

The templates are applied every days, and sometimes one day, you got error 4109 on an EA launched with a template. On the "Main" EA there is a button to apply the templates manually, and when you do it, all is back to normal...until next time it will happen.

It's now again 2 years later but I've been running into exactly the same issue. In my case, the function

ChartApplyTemplate()

was called within the function

OnTimer()

which seems to cause the issue under some circumstances. After moving it to the event

OnTick()

the issue seem to be solved. Additionally, calling

ChartRedraw()
after applying the template seems to be a good idea. 
Reason: