#import "user32.dll" int RegisterWindowMessageW(string MessageName); int PostMessageW(int hwnd,int msg,int wparam,uchar &Name[]); #import #define INDICATOR_NAME "Indicator_name" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void StartCustomIndicator(int hWnd,string IndicatorName,bool AutomaticallyAcceptDefaults=false) { uchar name2[]; StringToCharArray(IndicatorName,name2,0,StringLen(IndicatorName)); int MessageNumber=RegisterWindowMessageW("MetaTrader4_Internal_Message"); int r=PostMessageW(hWnd,MessageNumber,15,name2); Sleep(10); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { //--- // In my code where I launch the indicator int hWnd=WindowHandle(Symbol(),0); StartCustomIndicator(hWnd,INDICATOR_NAME); return(INIT_SUCCEEDED); }
Alain Verleyen:
Thanks, it has worked now, but it works only from second attemp. If i start ea, indicator call returns error fail to open / .ex4[123]. If the ea is already attached to a chart and i try to re attach it, then it works. How this can be solved?
Georgiy Liashchenko:
Are you sure?
...In mql4 there is no command which would add an indicator to a chart like in mql5 ChartIndicatorAdd(). It is really sad....
Vasyl Nosal:
Are you sure?
Well if you know some, please share... :)
Are you sure?
Georgiy Liashchenko:
Well if you know some, please share... :)
Well if you know some, please share... :)
:))))))))))))))))))))))))))))))))))))))))))))))))))
Oh sorry. Few minutes.
Hmm. I thought that it is in mql4.
Maybe this will help you
ChartApplyTemplate()
Vasyl Nosal:
Yes, but thats not a case as for example i sell ea and a client want to use it, he doesnt have a same template. Even if i give it with file, he may prefer different outlook. Therefore i want to initialize indicator from ea.
:))))))))))))))))))))))))))))))))))))))))))))))))))
Oh sorry. Few minutes.
Hmm. I thought that it is in mql4.
Maybe this will help you
ChartApplyTemplate()
Georgiy Liashchenko:
Yes, but thats not a case as for example i sell ea and a client want to use it, he doesnt have a same template. Even if i give it with file, he may prefer different outlook. Therefore i want to initialize indicator from ea.
Yes, but thats not a case as for example i sell ea and a client want to use it, he doesnt have a same template. Even if i give it with file, he may prefer different outlook. Therefore i want to initialize indicator from ea.
Hmm. Maybe than add indicator in EA using "resourse".
#resource "\\Indicators\\SampleIndicator.ex4" int OnInit() { double value=iCustom(_Symbol,_Period,"::Indicators\\SampleIndicator.ex4",0,0);
Vasyl Nosal:
doesn't work, ea gets handle but no indicator
Hmm. Maybe than add indicator in EA using "resourse".
Georgiy Liashchenko:
doesn't work, ea gets handle but no indicator
doesn't work, ea gets handle but no indicator
It is not add indicator to chart. It compile ind in ea ex.4 file.
Maybe write to srvice desk and ask they to add ChartIndicatorAdd() like in mql5?

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
Hello people,
I am trying to solve the current problem. In mql4 there is no command which would add an indicator to a chart like in mql5 ChartIndicatorAdd(). It is really sad.
I want my ea to initiate an indicator. Scrolling forums i came across with such solution but it isn't working properly. Please help!
This code tries to launch the indicator, but it doesn't read the file name properly. It tries to open only (first letter of indicator name).ex4 or I.ex4
Obvious solution was chararray but compiler returns error "parametr conversion not allowed". So how can we solve it?