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

 

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 

 
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.

 

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.

 
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.

 

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.

 

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.

 

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

i call that improvement.

 
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?
 

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.

 
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. 

 

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.

Reason: