Skip to content
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

MT5 connection problems with Windows Forms #265

Open
ljchuello opened this issue Jan 13, 2022 · 1 comment
Open

MT5 connection problems with Windows Forms #265

ljchuello opened this issue Jan 13, 2022 · 1 comment

Comments

@ljchuello
Copy link

Hello.

I have followed each of the instructions step by step, and despite this I cannot connect.

I always get the connection status: Mt5ConnectionState.Failed

` static readonly EventWaitHandle _connnectionWaiter = new AutoResetEvent(false);
static readonly MtApi5Client _mtapi = new MtApi5Client();

    public Form1()
    {
        // Init
        InitializeComponent();

        _mtapi.ConnectionStateChanged += _mtapi_ConnectionStateChanged;
        
        _mtapi.BeginConnect("127.0.0.1", 8228);
        _connnectionWaiter.WaitOne();
    }

    private void _mtapi_ConnectionStateChanged(object sender, Mt5ConnectionEventArgs e)
    {
        switch (e.Status)
        {
            case Mt5ConnectionState.Connecting:
                Console.WriteLine("Connnecting...");
                break;
            case Mt5ConnectionState.Connected:
                Console.WriteLine("Connnected.");
                _connnectionWaiter.Set();
                break;
            case Mt5ConnectionState.Disconnected:
                Console.WriteLine("Disconnected.");
                _connnectionWaiter.Set();
                break;
            case Mt5ConnectionState.Failed:
                Console.WriteLine("Connection failed.");
                _connnectionWaiter.Set();
                break;
        }
    }`
@lazou
Copy link

lazou commented Jan 13, 2022

Hi @ljchuello ,

did you tried to connect to an expert of a chart or did you wanted to connect to a backtesting setup?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants