Issue #41: Refactored MtApi5.mq5 - removed unnecessary variables

This commit is contained in:
DW
2017-09-29 15:48:46 +03:00
parent ce8cfbbb70
commit 5a3407e47c
2 changed files with 13 additions and 15 deletions
BIN
View File
Binary file not shown.
+13 -15
View File
@@ -43,15 +43,13 @@ input int Port = 8228;
int ExpertHandle; int ExpertHandle;
string message; //string message;
string _error; string _error;
string _response_error; string _response_error;
bool isCrashed = false; bool isCrashed = false;
bool IsRemoteReadyForTesting = false; bool IsRemoteReadyForTesting = false;
string commentValue;
string PARAM_SEPARATOR = ";"; string PARAM_SEPARATOR = ";";
int OnInit() int OnInit()
@@ -78,8 +76,6 @@ void OnTick()
int preinit() int preinit()
{ {
StringInit(message, 1000, 0);
StringInit(commentValue, 1000, 0);
StringInit(_response_error,1000,0); StringInit(_response_error,1000,0);
return (0); return (0);
@@ -133,7 +129,7 @@ int init()
if (!initExpert(ExpertHandle, Port, Symbol(), Bid, Ask, IsTesting(), _error)) if (!initExpert(ExpertHandle, Port, Symbol(), Bid, Ask, IsTesting(), _error))
{ {
MessageBox(message, "MtApi", 0); MessageBox(_error, "MtApi", 0);
isCrashed = true; isCrashed = true;
return(1); return(1);
} }
@@ -175,9 +171,9 @@ int deinit()
{ {
if (isCrashed == 0) if (isCrashed == 0)
{ {
if (!deinitExpert(ExpertHandle, message)) if (!deinitExpert(ExpertHandle, _error))
{ {
MessageBox(message, "MtApi", 0); MessageBox(_error, "MtApi", 0);
isCrashed = true; isCrashed = true;
return (1); return (1);
} }
@@ -194,9 +190,9 @@ int start()
double Bid = last_tick.bid; double Bid = last_tick.bid;
double Ask = last_tick.ask; double Ask = last_tick.ask;
if (!updateQuote(ExpertHandle, Symbol(), Bid, Ask, message)) if (!updateQuote(ExpertHandle, Symbol(), Bid, Ask, _error))
{ {
Print("updateQuote: [ERROR] ", message); Print("updateQuote: [ERROR] ", _error);
} }
return (0); return (0);
@@ -3035,15 +3031,17 @@ void PrintResponseError(string commandName, string error = "")
void ReadMqlTradeRequestFromCommand(MqlTradeRequest& request) void ReadMqlTradeRequestFromCommand(MqlTradeRequest& request)
{ {
string symbol; string symbol;
string comment;
int tmpEnumValue; int tmpEnumValue;
ulong m_magicValue = 0; ulong magic = 0;
StringInit(symbol, 100, 0); StringInit(symbol, 100, 0);
StringInit(comment, 1000, 0);
getIntValue(ExpertHandle, 0, tmpEnumValue, _error); getIntValue(ExpertHandle, 0, tmpEnumValue, _error);
request.action = (ENUM_TRADE_REQUEST_ACTIONS)tmpEnumValue; request.action = (ENUM_TRADE_REQUEST_ACTIONS)tmpEnumValue;
getULongValue(ExpertHandle, 1, m_magicValue, _error); getULongValue(ExpertHandle, 1, magic, _error);
request.magic = m_magicValue; request.magic = magic;
getULongValue(ExpertHandle, 2, request.order, _error); getULongValue(ExpertHandle, 2, request.order, _error);
getStringValue(ExpertHandle, 3, symbol, _error); getStringValue(ExpertHandle, 3, symbol, _error);
request.symbol = symbol; request.symbol = symbol;
@@ -3061,8 +3059,8 @@ void ReadMqlTradeRequestFromCommand(MqlTradeRequest& request)
request.type_time = (ENUM_ORDER_TYPE_TIME)tmpEnumValue; request.type_time = (ENUM_ORDER_TYPE_TIME)tmpEnumValue;
getIntValue(ExpertHandle, 13, tmpEnumValue, _error); getIntValue(ExpertHandle, 13, tmpEnumValue, _error);
request.expiration = (datetime)tmpEnumValue; request.expiration = (datetime)tmpEnumValue;
getStringValue(ExpertHandle, 14, commentValue, _error); getStringValue(ExpertHandle, 14, comment, _error);
request.comment = commentValue; request.comment = comment;
getULongValue(ExpertHandle, 15, request.position, _error); getULongValue(ExpertHandle, 15, request.position, _error);
getULongValue(ExpertHandle, 16, request.position_by, _error); getULongValue(ExpertHandle, 16, request.position_by, _error);
} }