how to attach an EA to a chart programmatic - page 2

 
cesarz18:


Hi anvarb

I setting this configuration but does not work

enable expert advisor, enable

disable expert when the account has been changed, disable
disable expert when the profile has been changes, disable

allow live tarding, enable
ask manual confirmation, disable

alloe dll import, enable
confirm dll funtion calls, enable
allow external expert imports, enable

Try to use another EA, if same problem
Call to your Trading House, look like your account in server side EA not enabled
 

other EA work fine, thanks

 
cesarz18:

other EA work fine, thanks


are you attaching EA to chart programmatic?
 
Please help. How to attach EA to chart.
 

send me via PM

 

cesarz18 this is a indicator not an EA & please next time, use the original post (https://www.mql5.com/en/forum/131564), don't mix with others

 

thanks

 

Hi guys,

I am dealing with the same thing - open new chart (my code is correct) + open other EA on new chart (code no works valid)

Can you help me, please?

Code for open new chart:

#import "user32.dll"
   int GetAncestor(int hWnd, int gaFlags);
   int GetDlgItem(int hDlg, int nIDDlgItem);
   int PostMessageA(int hWnd, int Msg, int wParam, int lParam);
#import

#define WM_COMMAND   0x0111
#define WM_KEYDOWN   0x0100
#define VK_HOME      0x0024
#define VK_DOWN      0x0028

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
// New charts opens from the "Market Watch" window with the DEFAULT.TPL template.
void start()
{   
ChartWindow("GOLD");
}

//+------------------------------------------------------------------+
//| Open a new chart                                                 |
//+------------------------------------------------------------------+
int ChartWindow(string SymbolName)
{
   int hFile, SymbolsTotal, hTerminal, hWnd;

   hFile = FileOpenHistory("symbols.sel", FILE_BIN|FILE_READ);
   if(hFile < 0) return(-1);

   SymbolsTotal = (FileSize(hFile) - 4) / 128;
   FileSeek(hFile, 4, SEEK_SET);

   hTerminal = GetAncestor(WindowHandle(Symbol(), PERIOD_M1), 2);

   hWnd = GetDlgItem(hTerminal, 0xE81C);
   hWnd = GetDlgItem(hWnd, 0x50);
   hWnd = GetDlgItem(hWnd, 0x8A71);

   PostMessageA(hWnd, WM_KEYDOWN, VK_HOME, 0);

   for(int i = 0; i < SymbolsTotal; i++)
   {
      if(FileReadString(hFile, 12) == SymbolName)
      {
         PostMessageA(hTerminal, WM_COMMAND, 33160, 0);
         return(0);
      }
      PostMessageA(hWnd, WM_KEYDOWN, VK_DOWN, 0);
      FileSeek(hFile, 116, SEEK_CUR);
   }

   FileClose(hFile);

   return(-1);
}

Code for insert EA on chart from this thread:

PostMessageA(hTerminal, WM_COMMAND, 33160, 0);
Sleep(500); // u should give some time to open the chart
int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message");
PostMessageA(hTerminal, MessageNumber, 14, "myEA");

I cannot implementations this code. :-(

Thank you for help!!!

Reason: