Embed MetaTrader5 in C#

 

Is it possible to embed MetaTrader5 in C# say, a window? I have been to write a program that will open MT4/5 but , but if I try to embed into "window" in C# it simply won't work.

Hoping there is a solution.  

 

Basically the idea is to use the native Win32 API to get the handle of the MT5 terminal window and set its parent to the handle of your own window then set the bounds of the MT5 window to the client rectangle of your window. You said it simply won't work so i asume that you already tried this. Maybe it doesn't work because the MT5 terminal window is already a MDI container and the behaviour is undefined. Try changing other window styles using SetWindowLong but i doubt it gona work.

You can always go for a different aproach by maximizing your window, making it top most then launch the MT5 terminal, own its window (change modal to behave like a dialog box), set the location and size to your window's client rectange and finally if you're lucky change the styles of the MT5 window and remove the resizable border and/or the title bar. This will disable user input for your window though.

 

Thanks so much!!

 
Exposing C# code to MQL5 using unmanaged exports
Exposing C# code to MQL5 using unmanaged exports
  • 2011.02.09
  • investeo
  • www.mql5.com
In this article I presented different methods of interaction between MQL5 code and managed C# code. I also provided several examples on how to marshal MQL5 structures against C# and how to invoke exported DLL functions in MQL5 scripts. I believe that the provided examples may serve as a basis for future research in writing DLLs in managed code. This article also open doors for MetaTrader to use many libraries that are already implemented in C#.