Since Feb, 2014 Build 600, all strings are Unicode. RegisterWindowMessageA and PostMessageA will never work.
Whether the adjusted code will work is doubtful.
Create a template with the indicator added and then have EA call ChartApplyTemplate - MQL4 Documentation
The real question is why are you trying to do this? Indicators need to be visible only for Humans. EA's just get their value via iCustom.
Thanks for the reply.
To answer your question why I need this: I want to visually analyze my EA and see how my EA buys/sells when the indicator changes. Yes, I could add the indicator manually, but I love things that are automated.
With regards to the unicode strings: will RegisterWindowMessageA and PostMessageA never-ever work, or should they work if I convert the strings to ANSI and pass them to the functions?
Other people who are interested. I've managed to get it working:
#import "user32.dll" int RegisterWindowMessageW(string MessageName); int PostMessageW(int hwnd, int msg, int wparam, char &Name[]); #import string name = "MyIndicator"; char name2[]; StringToCharArray(name , name2); int MessageNumber = RegisterWindowMessageW("MetaTrader4_Internal_Message"); int r = PostMessageW(hWnd, MessageNumber, 15, name2);
Other people who are interested. I've managed to get it working:
}
Can somebode check this code in the latest 880 build?
For me it is crashing mt4, though after restarting the mt4 ATR indicator is on the chart, so it was attached before the crash.
With using SendMessageW instead of PostMessageW - no crash, but indicator's dialog window appears and waits for user input (calling keybd_event(13, 0, 0, 0) does not work).
Can somebode check this code in the latest 880 build?
For me it is crashing mt4, though after restarting the mt4 ATR indicator is on the chart, so it was attached before the crash.
With using SendMessageW instead of PostMessageW - no crash, but indicator's dialog window appears and waits for user input (calling keybd_event(13, 0, 0, 0) does not work).
Hi,
Any update, on getting the code to work on current build.
The SendMessageW instead of PostMessageW works but as nickbilak says indicator's dialog window appears and waits for user input.
Anyone have the code to close the dialog window please ???
The SendMessageW instead of PostMessageW works but as nickbilak says indicator's dialog window appears and waits for user input.
Anyone have the code to close the dialog window please ???
It's in the original code at https://www.mql5.com/en/forum/115967
Thanks for the help.
Works now BUT ....
had to put the keybd_event(13, 0, 0, 0); before the SendMessageW(hWnd, MessageNumber, 15, name2)
otherwise it did not work ... instead it left dialog open and then opened the pair input box at base of chart.
MM
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I know that this question has been asked before, but I can't get it to work. I hope someone can help.
From my custom EA, I want to programmatically add my custom indicator to a subwindow of the chart the EA was added to. I've managed to do this in MQL5 with ChartIndicatorAdd. So, I have my indicator which is added to a separate window (#property indicator_separate_window) and from my EA, I'm calling the following code from https://www.mql5.com/en/forum/115967 :
However, when I execute this code, nothing is happening. Am I doing something wrong? Also, is it possible to provided parameters to the indicator using this manner?