MT4 Manager API => .Net ClrWrapper

﹥>﹥吖頭↗ 提交于 2019-12-25 17:14:09

问题


I am using mtmanapi.dll with a .Net CLR wrapper

I am getting correct Ask and Bid values for symbols without any special characters in the Symbol name - ( e.g. EURUSD, GBPUSD and so on ), but if symbols have some special character in it ( e.g. EURUSD', GBPUSD0 and so on ), then it's not fetching Ask and Bid value using a SymbolInfoGet() method.


回答1:


It should work and below code returns quotes for US100, OIL.WTI, 225JPY from my server. I am using SymbolInfoUpdated() however it's similar to SymbolInfoGet(). But there are few notes:

1) you might need to call mt.SymbolsRefresh(); and mt.SymbolAdd(symbol.Name); before switching to pumping

2) SymbolInfoGet() will return you last received quote in pumping. So if you connect on Saturday and call it, it won't return anything until Monday

using (var mt = new ClrWrapper(new ConnectionParameters {Login = 0, Password = "", Server = "" }))
{
    var symbols = mt.CfgRequestSymbol();
    mt.SymbolsRefresh();
    foreach (var symbol in symbols)
    {
        mt.SymbolAdd(symbol.Name);
    }
    mt.PumpingSwitchEx(PumpingMode.Default);

    mt.BidAskUpdated += (sender, args) =>
    {
        var total = 0;
        do
        {
            var symbolsInfos = mt.SymbolInfoUpdated();
            foreach (var symbolInfo in symbolsInfos)
            {                            
                if (!symbolInfo.Symbol.All(char.IsLetter))
                {
                    Console.WriteLine("{0} {1} {2}", DateTime.Now, symbolInfo.Symbol, symbolInfo.Bid);
                }
            }
            total = symbolsInfos.Count;
        } while (total > 0);
    };

    Console.ReadKey();
}


来源:https://stackoverflow.com/questions/37570922/mt4-manager-api-net-clrwrapper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!