Get my balance from metatrader 5 with c# application(WinForm)

 

hello,

I think in principle it's very useful to open up possible resources and find this article is very intersting. 

But I'm not very experienced programmer and therefore I have some question.


I have winform application with C# & .Net4  and I have an account (Demo or Real) in my broker(Alpari) and with metatrader 5.


Now my problem: 

1- How can i get and show my balance in C# application?

2- How can i show my account history in listbox?



best regards

 
FirstLine:

hello,

I think in principle it's very useful to open up possible resources and find this article is very intersting. 

But I'm not very experienced programmer and therefore I have some question.


I have winform application with C# & .Net4  and I have an account (Demo or Real) in my broker(Alpari) and with metatrader 5.


Now my problem: 

1- How can i get and show my balance in C# application?

2- How can i show my account history in listbox?



best regards

You need to create an EA that writes to a file and then your C# app reads the file. Make sure you use a try/catch in C# in case the file is busy, so it fails gracefully until the next timer request.

There are much more complicated alternatives like pipes, but do some research on fileWrite() in mql5 and it's quite easy to implement. 

 
Masood Heidarnia:

hello,

I think in principle it's very useful to open up possible resources and find this article is very intersting. 

But I'm not very experienced programmer and therefore I have some question.


I have winform application with C# & .Net4  and I have an account (Demo or Real) in my broker(Alpari) and with metatrader 5.


Now my problem: 

1- How can i get and show my balance in C# application?

2- How can i show my account history in listbox?



best regards

 

I've gone a different approach. Instead of using IPC, I'm creating a Thread with the MT4 expert, which then communicates back via simply setting some shared attributes.

It's still a work in progress, and not tested yet. But initial functionality seems to do the trick:

Instructions and source are here: 

https://github.com/jseparovic/MQL4CSharp 

Reason: