Download MetaTrader 5

How to prevent the user from changing the symbol and/or account in the current chart?

To add comments, please log in or register
Searching on MQL5.community is performed in all sections. Try it!
Doerk Hilger
1154
Doerk Hilger 2015.10.01 16:52 

Hi there,

maybe I overlooked the function, but how is it possible to prevent the user from changing the current symbol in the current chart? In my opinion, it´s  a no-go that a user can kill the EA performance by simply dropping a new symbol on the chart, because within the OnDeInit() I have no chance to cancel this process, which automatically would result in a position-disaster when the user did this just like that.

Same with account. I need a possibility to prevent the user from changing the account when the EA is active.

How can this be done?

Thanks

Doerk 

Ex Ovo Omnia
3121
Ex Ovo Omnia 2015.10.01 19:20  
Doerk:

Hi there,

maybe I overlooked the function, but how is it possible to prevent the user from changing the current symbol in the current chart? In my opinion, it´s  a no-go that a user can kill the EA performance by simply dropping a new symbol on the chart, because within the OnDeInit() I have no chance to cancel this process, which automatically would result in a position-disaster when the user did this just like that.

Same with account. I need a possibility to prevent the user from changing the account when the EA is active.

How can this be done?

Thanks

Doerk 

In case you talk about MT4, you can protect the chart from timeframe&symbol change (both by code and GUI) by marking it offline and generating blind scheduled ticks from the EA to refresh the host chart. But I would not go this way, I would rather save EA temporary values and reload them on init.

No idea how to protect the EA against changing the account.

Doerk Hilger
1154
Doerk Hilger 2015.10.01 19:59  

Thank you for you reply. I already assumed something like that. The values are saved anyway, but that does not help in my case. I think I have put in a warning message and after a loss of 1000 dollars because of that, the user surely won´t do it again ;) 

To be honest, this should be improved by MetaQuotes.

Alain Verleyen
Moderator
30707
Alain Verleyen 2015.10.01 20:58  
Doerk:

...

To be honest, this should be improved by MetaQuotes.

Why ?

You should improve your code. You already have all what is needed to monitor a change of symbol/timeframe/account and act accordingly. I don't want Metaquotes to impose new restrictions, they already take enough decisions in place of traders/programmers.

If you need help please explain your problem with some details.

Marco vd Heijden
Moderator
4685
Marco vd Heijden 2015.10.01 21:41  

this is simple,

you do

  string chart_symbol=Symbol();

then use

chart_symbol

throughout the rest of the EA,

any change of symbol will not affect the symbol the ea is showing.

Better still is to not even use chart related settings like Symbol() and timeframe, it is perfectly possible to do without and doing so excludes problems rising related to chart settings.

i say this is something that is related to the coder and not to Metaquotes.

Doerk Hilger
1154
Doerk Hilger 2015.10.02 17:04  

EDIT: What I wrote was bullshit ;)

New try: I have a chart that contains several interactive lines, all controlled by the EA. These lines are connected to active trades, and they need every tick. When  the chart is changed, the whole EA gets obsolete and the only reason is: Closing all positions. It makes no sense to save and restore, because the price will be at another position when the chart opens again and those lines cannot become corrected, in other words, would decide to close the positions anyway because the management would no longer work / make sense.

For this, I need a security which prevents the user from changing the chart and/or the account.

Marco vd Heijden
Moderator
4685
Marco vd Heijden 2015.10.02 19:58  

or you simply make sure it runs on any chart any symbol any time frame.

i call that improvement.

Doerk Hilger
1154
Doerk Hilger 2015.10.03 00:06  
Marco vd Heijden:

or you simply make sure it runs on any chart any symbol any time frame.

i call that improvement.

Thats what it already does. And?
Marco vd Heijden
Moderator
4685
Marco vd Heijden 2015.10.03 08:47  

meaning you can switch symbol, timeframe at any time without affecting the EA's operation.

if your ea freezes up, crashes, stops working , or closes positions when you change time frame its a result from bad coding.

Doerk Hilger
1154
Doerk Hilger 2015.10.03 09:54  
Marco vd Heijden:

meaning you can switch symbol, timeframe at any time without affecting the EA's operation.

if your ea freezes up, crashes, stops working , or closes positions when you change time frame its a result from bad coding.

The question was clear, if you don´t know the answer, it´s ok. 

Marco vd Heijden
Moderator
4685
Marco vd Heijden 2015.10.03 10:52  

the answer is clear too.

it's not possible to prevent just that.


but it is possible to get to a workable solution by improving your code.

i.e they can still switch symbol and time frame, but it will not affect your EA; you are approaching it from the wrong end.

trying to change the program to meet your needs, it should be the way around, change your code.

12
To add comments, please log in or register