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

 

ForexTools:

Since chart objects and global variables must survive both restarts and recompilations - the check will always work correctly. unless you manually delete either global or object from the list of objects - but this is almost paranoid :)))

Just replace the global variable with something more reliable. But it seems to be the same.
 
sanyooooook:
When terminal crashes, graphical objects created in last session are not saved. Correct me if I'm wrong.


Yes, they don't. But the problem statement here is not complete. We need to be more specific.

If, for example, we want to connect the indicators - Expert Advisor, the graphical object should be created by indicators. This will be a robust connection.

If you just want to bind to a particular window, say to a certain timeframe, then you should additionally use this feature - the timeframe, as an identifying attribute.

But if you need total resistance to nuclear blasts, then only launching with command line parameters will help.

 
sanyooooook:
When the terminal goes down...

well in THIS case nothing is guaranteed at all.

In principle - the solution with the label object and a global variable is fine, with a good safety net. it will not allow to start a second time, and I'll scold the messages so that I do not forget to delete it and the second time neither at crash nor at restart of the terminal there will be two copies ;)

 
TheXpert:
Just replace the global variable with something more reliable. But it seems to be the same.

Why don't you like global variables? Well, sometimes they disappear :) Even if they are rewritable :))) Well, what do you want, it's a product, it's molded. You just have to factor it into the algorithm. Files, by the way, can also disappear when the file system fails.
 

Option 1 (for sane users): Create a global variable on the Expert Advisor startup. If a global variable is detected on startup, the message box opens "Tra la la... Expert is locked, allows one instance, remove unnecessary".

Variant 2 (if programming services are provided to psychiatric patients): PostMessageA(,WM_CLOSE,,); - kill window with superfluous EA.

 

Integer:

Variant 2 (if programming services are rendered to patients of mental clinic): PostMessageA(,WM_CLOSE,,); - kill window with unnecessary EA.

Too cruel - it's easier to make Expert Advisors as a looped script - the effect is the same. Man, I'll have to restart it manually... Closing it is too brutal anyway :)
 
ForexTools:

Because that's exactly what I want a "solution recommendation". that's what I asked for in my first post - that's why I took your idea that way too.

which is why I see the validity of many "ideas" even DOTO as their..... ;)

if i'm wrong about you - write some EA code that does nothing but prevent your second copy from running. check that it really works when recompiling and restarting the terminal and post the code here - everything will fall into place ;)

So you're offering me to work for you. Why don't you name a price?
 
TheXpert:
Too cruel - it's easier to make EAs as a looped script - same effect. Geez, then you'd have to restart it manually... It's too brutal to close anyway :)


Of course it closes too hard, but it closes :)

 
Integer:
If programming services are provided to patients in a mental hospital

:)))))))

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.

 
Candid:
So you are offering me to work for you. Why don't you tell me the price?

Relax ;)

I communicate on this forum with fellow craftsmen. those who think they can help me - they 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 his thinking, who did not want - silently went to read other topics.