-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help,no connection to Mt4 in VS Windows Forms. #257
Comments
Hi nopsynops,
|
Thanks a lot
… Hi nopsynops,
The following is the basic example, please take a look.
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using MtApi;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
private MtApiClient client;
private string symbol = "USDJPY";
public Form1()
{
InitializeComponent();
client = new MtApiClient(); //Initialize client
/*You need to add the event handler here for detecting connection*/
client.ConnectionStateChanged += Client_ConnectionStateChanged;
client.BeginConnect(8222); //Begin Connection! Remark-> The port should be same as your EA input in MT4
}
private void Client_ConnectionStateChanged(object sender, MtConnectionEventArgs e)
{
/*Once connection established, your EA logic can be implement*/
if(e.Status== MtConnectionState.Connected)
{
MessageBox.Show(client.iClose(symbol, ChartPeriod.PERIOD_MN1, 0).ToString());
}
}
}
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage", "potentialAction": { ***@***.***": "ViewAction", "target": "#257 (comment)", "url": "#257 (comment)", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can show an example Mt4 with Windows Forms.
Please.
The text was updated successfully, but these errors were encountered: