Open Order Window

 

Hi,

is there a possibility to let an EA open the orderwindow of my terminal?

 
sunshineh:

Hi,

is there a possibility to let an EA open the orderwindow of my terminal?

Hi,

You can do that by using some Windows API functions. Below is the code you can use:

#import "user32.dll"
        int GetAncestor(int hWnd, int gaFlags);
        void keybd_event(int bVk,int bScan,int dwFlags,int dwExtraInfo);
#import

..........

void OpenTradeWindow()
{
   int hTerminal = 0;
  
   hTerminal = GetAncestor(WindowHandle(Symbol(), Period()), 2);
   
   if(hTerminal != 0) 
   {
      keybd_event(0x78,0x45,0x0001,0);
      keybd_event(0x78,0x45,0x0001|0x2,0);
   }
}

Cheers

 

Hi,

thank you very much, it works great!!!

Can I also give a Ordersize from 2.5lot to the window??

 

it's not more simple to use OrderSend() function