Execute an existing EA from a script/ea ? - page 3

To add comments, please log in or register
Tom Sasson
187
Tom Sasson  
shoxie:

The page where you read about threads is here:

https://docs.mql4.com/runtime/running

Each script and EA runs its own thread. Only indicators share a common thread with the MT4 GUI. I'm well aware of this, which I why I avoid using while loops in all my indicators, so that the indicator doesn't go into an infinite loop and freeze MT4's GUI.

I use several WinAPI functions in my scripts and indicators. Only PostMessageW has caused a problem so far.

....sigh....I wonder what the problem is with PostMessageW in a script. I haven't tested it in an EA. Does it work without crashing the terminal?I

As I said before: "Consider using your code in an EA and this way the PostMessageW command will not crash your MT4."

Stanislav Korotky
24553
Stanislav Korotky  
shoxie:

My situation is this:

I would like to place an indicator on the chart just as I'm about to place a trade. I don't want the indicator running constantly. I would like to press a hotkey and then have the indicator be instantly placed on the chart without it showing the config dialog box. I would like the script to be linked to the hotkey, to run just once and perform just this very task - placing the indicator on the chart and getting rid of the dialog box without any manual input from me. The reason I go through the trouble of trying to get a script to do all this is to get rid of the config dialog box. I've got multiple charts open and I don't want to be clicking OK to get rid of the dialog box all the time. One hotkey press and the indicator should be up and running. That's what I want.

So you're saying that PostMessageW only crashes the terminal when it's called from a script? Why does it work in an EA and not in a script? What is the deeper programmatic reason for this?

Probably you can prepare a template with this indicator (and required parameters) and then just switch to/from this template when needed. Hence you don't need any scripts, Windows messaging, or other automation.

shoxie
29
shoxie  
Stanislav Korotky:

Probably you can prepare a template with this indicator (and required parameters) and then just switch to/from this template when needed. Hence you don't need any scripts, Windows messaging, or other automation.

I don't want to go through the trouble of changing the chart entirely by using a new template. This means elaborating my code for deinitialization and reinitialization for template change. There's also other stuff on the chart that I don't want to lose. I'm very intent on using a script, since it can be activated by a hotkey, runs only once and removes itself from the chart. It's effect is minimal.

Never mind, just leave it. It doesn't look like there is a decent alternative to PostMessageW which will close the config dialog from within a script.
123
To add comments, please log in or register