Hi there. I stumbled across your a 2018 on how to add an indicator to a chart in MT4 using a ChartCustomIndicator() function.
I have a problem because I want to add 2 indicators using this routine, but for some reason, I can only manage to add the first 1 and the second returns file cannot be found. Can you help?
Function:
int StartCustomIndicator(int hWnd,string IndicatorName, bool AutomaticallyAcceptDefaults=true) { Sleep(50);
uchar name[];
StringToCharArray(IndicatorName,name,0,StringLen(IndicatorName)); int MessageNumber=RegisterWindowMessageW("MetaTrader4_Internal_Message"); int r=PostMessageW(hWnd,MessageNumber,15,name); Sleep(50); if(AutomaticallyAcceptDefaults) { int ind_settings = FindWindowW(NULL, "Custom Indicator - "+IndicatorName); PostMessageW(ind_settings,0x100,VK_RETURN,name); } return(INIT_SUCCEEDED); }
I have a problem because I want to add 2 indicators using this routine, but for some reason, I can only manage to add the first 1 and the second returns file cannot be found. Can you help?
Function:
int StartCustomIndicator(int hWnd,string IndicatorName, bool AutomaticallyAcceptDefaults=true)
{
Sleep(50);
uchar name[];
StringToCharArray(IndicatorName,name,0,StringLen(IndicatorName));
int MessageNumber=RegisterWindowMessageW("MetaTrader4_Internal_Message");
int r=PostMessageW(hWnd,MessageNumber,15,name);
Sleep(50);
if(AutomaticallyAcceptDefaults) {
int ind_settings = FindWindowW(NULL, "Custom Indicator - "+IndicatorName);
PostMessageW(ind_settings,0x100,VK_RETURN,name);
}
return(INIT_SUCCEEDED);
}
Call:
StartCustomIndicator(WindowHandle(Symbol(),0),"NVC");
StartCustomIndicator(WindowHandle(Symbol(),0),"Correlations MA");