How to ensure that the EA only works on the chart where it was first dropped - page 7

 
ForexTools:

Relax ;)

I communicate on this forum with fellow craftsmen. those who think they can help me - help. those who want money for their help - write about it and I decide whether to pay me or not. there have been cases (and more than once) when I have paid.

But besides payment, for a programmer there is interest in solving puzzles. so i planted one of them. who wanted to - had fun, trained their thinking, who did not want - silently went to read other topics.

Look at things in a narrow way :). It's my mind that I train all the time, only in the first post was a suggestion on your question, and in subsequent posts I satisfied my own interest, more of a sociological one. :)
 
ForexTools:

:)))))))

but nevertheless: created a global variable, the second run of EA checked its presence - it did not start. after one minute the terminal crashed but: the global variable remained.

when restarting the terminal, one single copy checks if it exists and does NOT start. so the object on the chart is still needed to identify "its chart" and start.




In that case, the issue is not solvable with global variables, but there was some advice here about opening a file - good advice.

 
I'll teach you how to solve this issue with global variables at a cost. If you're too lazy to read the thread.
 
gip:
I'll teach you how to solve this issue with global variables at a cost. If you're too lazy to read the thread.

Vadim's solution is the best ever!
 

I've already read, understood, comprehended, figured it out. I know how to code myself - so I can do it myself.

Thank you, thank you, thank you...

 
ForexTools:

I need to make the Expert Advisor work only in "one copy". I.e. I attach it to any chart for the first time and it works. If I then accidentally or intentionally attach it again to another chart, the second attachment should recognize that there is already running and do nothing.

Leaving the label in a global variable probably won't work. If I have two EAs attached and I recompile its text, then it's not clear which one of them will work first with its initem where I could create this global variable.

Who can suggest what? Any thoughts on how to do this?


interesting question ))) but no one mentioned the *.set file, which should be attached to every EA))

I have the same EA on five charts and different magicnum settings on each chart; by default magicnum=0 and if magicnum=0 then the EA does not do anything return full, it works after loading *.set because it has a different magicnum... This solves the recompilation problem, after that the default settings are magicnumer=0 and nothing happens until I load a set. Just go to any chart and no extra orders )) until I consciously load .set If I reload the terminal, it doesn't matter either what the default settings are, or the same as before, each copy with its own set ... is it like this or the question is humorous?

 
SJS:


And the truth is that everything is brilliantly simple!

In gip' s object variant, you allow trading by creating an object.

In the variant proposed by SJS, you allow trading by connecting settings file (you can simply change false to true in the external variable responsible for trading).

Both versions have manual confirmation of Expert Advisor start.

 
SJS:


interesting question ))) but no one told me about the *.set file, which is attached to every Expert Advisor))

Can you elaborate on where to look for this set?

I think the *.chr files are more promising :)

 

Guys.... I wanted a trivial "foolproofing". against accidental misbehaviour.

The trader deletes unnecessary things, leaves only one, clears all unnecessary globals, if necessary, and continues working quietly. that's it! the topic is over (imho).

 
ForexTools:

Guys.... I wanted a trivial "foolproofing". against accidental misbehaviour.

The trader deletes unnecessary things, leaves only one, clears all unnecessary globals, if necessary, and continues working quietly. that's it! the topic is over (imho).

Bad solution, requires some qualification, albeit minimal