
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hallo,paulepanke!
i tested You code for attach a expert to chart -sorry it work not!
give please a samle for attach expert name "profit" to active chart
with a script.
pansa
Replace all PosMessageA with PostMessageW and RegisterWindowMessageA with RegisterWindowMessageW.
This has been so since build 600+, when W (wide) or Unicode form of the functions was introduced.
Replace all PosMessageA with PostMessageW and RegisterWindowMessageA with RegisterWindowMessageW.
This has been so since build 600+, when W (wide) or Unicode form of the functions was introduced.
PostMessageW crashes the MT4 terminal when I use it from within a script to place an indicator. I'm using the latest build of MT4: v4.00 Build 1090 (19 May 2017). SendMessageW works in placing the indicator, but it won't allow for a simulated keyboard event which will get rid of the dialog box.
Is there an update to this whole method of placing an indicator/script/EA programmatically and then getting rid of the dialog box programmatically? Something which is compatible with the latest build of MT4?
PostMessageW crashes the MT4 terminal when I use it from within a script to place an indicator. I'm using the latest build of MT4: v4.00 Build 1090 (19 May 2017). SendMessageW works in placing the indicator, but it won't allow for a simulated keyboard event which will get rid of the dialog box.
Is there an update to this whole method of placing an indicator/script/EA programmatically and then getting rid of the dialog box programmatically? Something which is compatible with the latest build of MT4?
Are you using keybd_event from WinUser32.mqh ?
Are you using keybd_event from WinUser32.mqh ?
Thanks for responding. Yes I'm using the same function from WinUser32, but I included it at the top of my script:
Hello,
Is it possible run existing EA from a script/ea ?
If so, is it possible to define the ea settings like Pair, Timeframe and parameters ?
Thanks in advance,
Manu
Thanks for responding. Yes I'm using the same function from WinUser32, but I included it at the top of my script:
Why would you want to do that within a script?
Loading a script to a chart is the same operation as loading an EA/script/indicator to the chart.
Consider using your code in an EA and this way the PostMessageW command will not crash your MT4.
Why would you want to do that within a script?
Loading a script to a chart is the same operation as loading an EA/script/indicator to the chart.
Consider using your code in an EA and this way the PostMessageW command will not crash your MT4.
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?
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?
I am not sure, but I remember reading somewhere about it - an EA is working under a different thread, while scripts and indicators work under the MT4 GUI.
That is why when we're using WinAPI in indicators and scripts, we may harm the way MT4 works.
When doing the same in an Expert Advisor, it can implant internal messages to MT4 terminal without interrupting the total flow of the MT4 GUI.
Hotkeys, WinAPI - I'd rather use them in an EA and not under an infinite-loop running script.
I am not sure, but I remember reading somewhere about it - an EA is working under a different thread, while scripts and indicators work under the MT4 GUI.
That is why when we're using WinAPI in indicators and scripts, we may harm the way MT4 works.
When doing the same in an Expert Advisor, it can implant internal messages to MT4 terminal without interrupting the total flow of the MT4 GUI.
Hotkeys, WinAPI - I'd rather use them in an EA and not under an infinite-loop running script.
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?