Starting to work on MtApi (MT5) version 1.0.10

This commit is contained in:
vdemydiuk
2016-10-05 10:29:03 +03:00
parent 802b19b402
commit 5739423d6c
3 changed files with 30 additions and 48 deletions
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.9.0")] [assembly: AssemblyVersion("1.0.10.0")]
[assembly: AssemblyFileVersion("1.0.9.0")] [assembly: AssemblyFileVersion("1.0.10.0")]
BIN
View File
Binary file not shown.
+28 -46
View File
@@ -3,6 +3,8 @@
#include <Trade\SymbolInfo.mqh> #include <Trade\SymbolInfo.mqh>
#include <trade/trade.mqh> #include <trade/trade.mqh>
#property version "1.1"
#property description "MtApi (MT5) connection expert"
#import "MT5Connector.dll" #import "MT5Connector.dll"
bool initExpert(int expertHandle, int port, string symbol, double bid, double ask, string& err); bool initExpert(int expertHandle, int port, string symbol, double bid, double ask, string& err);
@@ -32,8 +34,6 @@
bool getDoubleValue(int expertHandle, int paramIndex, double& res); bool getDoubleValue(int expertHandle, int paramIndex, double& res);
bool getStringValue(int expertHandle, int paramIndex, string& res); bool getStringValue(int expertHandle, int paramIndex, string& res);
bool getBooleanValue(int expertHandle, int paramIndex, bool& res); bool getBooleanValue(int expertHandle, int paramIndex, bool& res);
// void verify(bool isDemo, string accountName, long accountNumber);
#import #import
input int Port = 8228; input int Port = 8228;
@@ -46,9 +46,6 @@ bool isCrashed = false;
string symbolValue; string symbolValue;
string commentValue; string commentValue;
double myBid;
double myAsk;
string PARAM_SEPARATOR = ";"; string PARAM_SEPARATOR = ";";
int OnInit() int OnInit()
@@ -69,9 +66,9 @@ void OnTick()
int preinit() int preinit()
{ {
message = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + ""; StringInit(message, 1000, 0);
symbolValue = "222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" + ""; StringInit(symbolValue, 1000, 0);
commentValue = "333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333" + ""; StringInit(commentValue, 1000, 0);
return (0); return (0);
} }
@@ -86,9 +83,7 @@ bool IsDemo()
int init() int init()
{ {
preinit(); preinit();
// verify(IsDemo(), AccountInfoString(ACCOUNT_NAME), AccountInfoInteger(ACCOUNT_LOGIN));
if (TerminalInfoInteger(TERMINAL_DLLS_ALLOWED) == false) if (TerminalInfoInteger(TERMINAL_DLLS_ALLOWED) == false)
{ {
@@ -110,17 +105,14 @@ int init()
return (1); return (1);
} }
long chartID= ChartID(); long chartID = ChartID();
ExpertHandle = ChartGetInteger(chartID, CHART_WINDOW_HANDLE); ExpertHandle = (int) ChartGetInteger(chartID, CHART_WINDOW_HANDLE);
MqlTick last_tick; MqlTick last_tick;
SymbolInfoTick(Symbol(),last_tick); SymbolInfoTick(Symbol(),last_tick);
double Bid = last_tick.bid; double Bid = last_tick.bid;
double Ask = last_tick.ask; double Ask = last_tick.ask;
myBid = Bid;
myAsk = Ask;
if (!initExpert(ExpertHandle, Port, Symbol(), Bid, Ask, message)) if (!initExpert(ExpertHandle, Port, Symbol(), Bid, Ask, message))
{ {
MessageBox(message, "MtApi", 0); MessageBox(message, "MtApi", 0);
@@ -154,42 +146,32 @@ int deinit()
int start() int start()
{ {
if (isCrashed == 0) MqlTick last_tick;
{ SymbolInfoTick(Symbol(),last_tick);
MqlTick last_tick; double Bid = last_tick.bid;
SymbolInfoTick(Symbol(),last_tick); double Ask = last_tick.ask;
double Bid = last_tick.bid;
double Ask = last_tick.ask;
if (executeCommand() != 0) if (!updateQuote(ExpertHandle, Symbol(), Bid, Ask, message))
{ {
CSymbolInfo mysymbol; Print("updateQuote: [ERROR] ", message);
mysymbol.Name (_Symbol);
mysymbol.RefreshRates();
Bid = mysymbol.Bid();
Ask = mysymbol.Ask();
if (myBid == Bid && myAsk == Ask)
{
return (0);
}
}
if (!updateQuote(ExpertHandle, Symbol(), Bid, Ask, message))
{
MessageBox(message, "MtApi", 0);
isCrashed = true;
return (1);
}
myBid = Bid;
myAsk = Ask;
} }
return (0); return (0);
} }
void OnTimer()
{
while(true)
{
int executedCommand = executeCommand();
if (executedCommand == 0)
{
return;
}
}
}
int executeCommand() int executeCommand()
{ {
int commandType = 0; int commandType = 0;