Used WM_TIMER message to perform commands in MQL expert

This commit is contained in:
vdemydiuk
2016-10-05 11:18:46 +03:00
parent 5739423d6c
commit 7aa2a1b691
4 changed files with 351 additions and 353 deletions
+341 -341
View File
@@ -21,57 +21,57 @@ using namespace System::Security;
#pragma pack(push, 1) #pragma pack(push, 1)
public struct CMqlRates public struct CMqlRates
{ {
__int64 time; // Period start time __int64 time; // Period start time
double open; // Open price double open; // Open price
double high; // The highest price of the period double high; // The highest price of the period
double low; // The lowest price of the period double low; // The lowest price of the period
double close; // Close price double close; // Close price
__int64 tick_volume; // Tick volume __int64 tick_volume; // Tick volume
int spread; // Spread int spread; // Spread
__int64 real_volume; // Trade volume __int64 real_volume; // Trade volume
}; };
public struct CMqlTick public struct CMqlTick
{ {
__int64 time; // Time of the last prices update __int64 time; // Time of the last prices update
double bid; // Current Bid price double bid; // Current Bid price
double ask; // Current Ask price double ask; // Current Ask price
double last; // Price of the last deal (Last) double last; // Price of the last deal (Last)
unsigned __int64 volume; // Volume for the current Last price unsigned __int64 volume; // Volume for the current Last price
}; };
public struct CMqlBookInfo public struct CMqlBookInfo
{ {
int type; // Order type from ENUM_BOOK_TYPE enumeration int type; // Order type from ENUM_BOOK_TYPE enumeration
double price; // Price double price; // Price
__int64 volume; // Volume __int64 volume; // Volume
}; };
#pragma pack(pop) #pragma pack(pop)
void convertSystemString(wchar_t* dest, String^ src) void convertSystemString(wchar_t* dest, String^ src)
{ {
pin_ptr<const wchar_t> wch = PtrToStringChars(src); pin_ptr<const wchar_t> wch = PtrToStringChars(src);
memcpy(dest, wch, wcslen(wch) * sizeof(wchar_t)); memcpy(dest, wch, wcslen(wch) * sizeof(wchar_t));
dest[wcslen(wch)] = '\0'; dest[wcslen(wch)] = '\0';
} }
bool VerifySignature(System::String^ inputData, System::String^ signature, System::String^ publicKey) bool VerifySignature(System::String^ inputData, System::String^ signature, System::String^ publicKey)
{ {
bool verifyResult = false; bool verifyResult = false;
try try
{ {
DSACryptoServiceProvider^ dsa = gcnew DSACryptoServiceProvider(); DSACryptoServiceProvider^ dsa = gcnew DSACryptoServiceProvider();
dsa->FromXmlString(publicKey); dsa->FromXmlString(publicKey);
array<System::Byte>^ data = UTF8Encoding::ASCII->GetBytes(inputData); array<System::Byte>^ data = UTF8Encoding::ASCII->GetBytes(inputData);
array<System::Byte>^ signatureData = Convert::FromBase64String(signature); array<System::Byte>^ signatureData = Convert::FromBase64String(signature);
verifyResult = dsa->VerifyData(data, signatureData); verifyResult = dsa->VerifyData(data, signatureData);
} }
catch(Exception^ e) catch(Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:VerifySignature(): failed. " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:VerifySignature(): failed. " + e->Message);
verifyResult = false; verifyResult = false;
} }
return verifyResult; return verifyResult;
} }
@@ -80,431 +80,431 @@ bool g_IsVerified = true;
void _stdcall verify(int isDemo, wchar_t* accountName, long accountNumber) void _stdcall verify(int isDemo, wchar_t* accountName, long accountNumber)
{ {
if (isDemo != 0) if (isDemo != 0)
{ {
g_IsVerified = true; g_IsVerified = true;
return; return;
} }
System::String^ signature = MtRegistryManager::ReadSignatureKey(gcnew String(accountName), accountNumber.ToString()); System::String^ signature = MtRegistryManager::ReadSignatureKey(gcnew String(accountName), accountNumber.ToString());
Resources::ResourceManager^ rm = gcnew Resources::ResourceManager(L"MT5Connector.cl", Assembly::GetExecutingAssembly()); Resources::ResourceManager^ rm = gcnew Resources::ResourceManager(L"MT5Connector.cl", Assembly::GetExecutingAssembly());
System::String^ inputData = gcnew System::String(accountName); System::String^ inputData = gcnew System::String(accountName);
inputData += accountNumber.ToString(); inputData += accountNumber.ToString();
System::String^ publicKey = rm->GetString(L"cl"); System::String^ publicKey = rm->GetString(L"cl");
g_IsVerified = VerifySignature(inputData, gcnew System::String(signature), publicKey); g_IsVerified = VerifySignature(inputData, gcnew System::String(signature), publicKey);
} }
int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, wchar_t* err) int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, wchar_t* err)
{ {
if (g_IsVerified == false) if (g_IsVerified == false)
{ {
System::String^ errorVerified = "Verification is failed!\nPlease contact with support."; System::String^ errorVerified = "Verification is failed!\nPlease contact with support.";
convertSystemString(err, errorVerified); convertSystemString(err, errorVerified);
Debug::WriteLine("[ERROR] MT5Connector:initExpert(): not verified"); Debug::WriteLine("[ERROR] MT5Connector:initExpert(): not verified");
return 0; return 0;
} }
try try
{ {
MT5Handler^ mtHander = gcnew MT5Handler(); MT5Handler^ mtHander = gcnew MT5Handler();
MtServerInstance::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHander); MtServerInstance::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHander);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
convertSystemString(err, e->Message); convertSystemString(err, e->Message);
Debug::WriteLine("[ERROR] MT5Connector:initExpert(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:initExpert(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall deinitExpert(int expertHandle, wchar_t* err) int _stdcall deinitExpert(int expertHandle, wchar_t* err)
{ {
try try
{ {
MtServerInstance::GetInstance()->DeinitExpert(expertHandle); MtServerInstance::GetInstance()->DeinitExpert(expertHandle);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
convertSystemString(err, e->Message); convertSystemString(err, e->Message);
Debug::WriteLine("[ERROR] MT5Connector:deinitExpert(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:deinitExpert(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err) int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err)
{ {
try try
{ {
MtServerInstance::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask); MtServerInstance::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
convertSystemString(err, e->Message); convertSystemString(err, e->Message);
Debug::WriteLine("[ERROR] MT5Connector:updateQuote(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:updateQuote(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendIntResponse(int expertHandle, int response) int _stdcall sendIntResponse(int expertHandle, int response)
{ {
try try
{ {
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendIntResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendIntResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendLongResponse(int expertHandle, __int64 response) int _stdcall sendLongResponse(int expertHandle, __int64 response)
{ {
try try
{ {
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendULongResponse(int expertHandle, unsigned __int64 response) int _stdcall sendULongResponse(int expertHandle, unsigned __int64 response)
{ {
try try
{ {
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseULong(response)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseULong(response));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendBooleanResponse(int expertHandle, int response) int _stdcall sendBooleanResponse(int expertHandle, int response)
{ {
try try
{ {
bool value = (response != 0) ? true : false; bool value = (response != 0) ? true : false;
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendBooleanResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendBooleanResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendDoubleResponse(int expertHandle, double response) int _stdcall sendDoubleResponse(int expertHandle, double response)
{ {
try try
{ {
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendDoubleResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendDoubleResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendStringResponse(int expertHandle, wchar_t* response) int _stdcall sendStringResponse(int expertHandle, wchar_t* response)
{ {
try try
{ {
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response))); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendStringResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendStringResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendVoidResponse(int expertHandle) int _stdcall sendVoidResponse(int expertHandle)
{ {
try try
{ {
MtServerInstance::GetInstance()->SendResponse(expertHandle, nullptr); MtServerInstance::GetInstance()->SendResponse(expertHandle, nullptr);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendVoidResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendVoidResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size) int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size)
{ {
try try
{ {
array<double>^ list = gcnew array<double>(size); array<double>^ list = gcnew array<double>(size);
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
list[i] = values[i]; list[i] = values[i];
} }
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendDoubleArrayResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendDoubleArrayResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size) int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size)
{ {
try try
{ {
array<int>^ list = gcnew array<int>(size); array<int>^ list = gcnew array<int>(size);
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
list[i] = values[i]; list[i] = values[i];
} }
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendIntArrayResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendIntArrayResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendLongArrayResponse(int expertHandle, __int64* values, int size) int _stdcall sendLongArrayResponse(int expertHandle, __int64* values, int size)
{ {
try try
{ {
array<System::Int64>^ list = gcnew array<System::Int64>(size); array<System::Int64>^ list = gcnew array<System::Int64>(size);
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
list[i] = values[i]; list[i] = values[i];
} }
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLongArray(list)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLongArray(list));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendLongArrayResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendLongArrayResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int size) int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int size)
{ {
try try
{ {
array<MtMqlRates^>^ list = gcnew array<MtMqlRates^>(size); array<MtMqlRates^>^ list = gcnew array<MtMqlRates^>(size);
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
MtMqlRates^ rates = gcnew MtMqlRates(); MtMqlRates^ rates = gcnew MtMqlRates();
rates->time = values[i].time; rates->time = values[i].time;
rates->open = values[i].open; rates->open = values[i].open;
rates->high = values[i].high; rates->high = values[i].high;
rates->low = values[i].low; rates->low = values[i].low;
rates->close = values[i].close; rates->close = values[i].close;
rates->tick_volume = values[i].tick_volume; rates->tick_volume = values[i].tick_volume;
rates->spread = values[i].spread; rates->spread = values[i].spread;
rates->real_volume = values[i].real_volume; rates->real_volume = values[i].real_volume;
list[i] = rates; list[i] = rates;
} }
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlRatesArray(list)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlRatesArray(list));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendMqlTickResponse(int expertHandle, CMqlTick* response, int size) int _stdcall sendMqlTickResponse(int expertHandle, CMqlTick* response, int size)
{ {
try try
{ {
MtMqlTick^ mtResponse = gcnew MtMqlTick(); MtMqlTick^ mtResponse = gcnew MtMqlTick();
mtResponse->time = response->time; mtResponse->time = response->time;
mtResponse->bid = response->bid; mtResponse->bid = response->bid;
mtResponse->ask = response->ask; mtResponse->ask = response->ask;
mtResponse->last = response->last; mtResponse->last = response->last;
mtResponse->volume = response->volume; mtResponse->volume = response->volume;
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlTick(mtResponse)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlTick(mtResponse));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendMqlTickResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendMqlTickResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall sendMqlBookInfoArrayResponse(int expertHandle, CMqlBookInfo values[], int size) int _stdcall sendMqlBookInfoArrayResponse(int expertHandle, CMqlBookInfo values[], int size)
{ {
try try
{ {
array<MtMqlBookInfo^>^ list = gcnew array<MtMqlBookInfo^>(size); array<MtMqlBookInfo^>^ list = gcnew array<MtMqlBookInfo^>(size);
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
MtMqlBookInfo^ info = gcnew MtMqlBookInfo(); MtMqlBookInfo^ info = gcnew MtMqlBookInfo();
info->type = values[i].type; info->type = values[i].type;
info->price = values[i].price; info->price = values[i].price;
info->volume = values[i].volume; info->volume = values[i].volume;
list[i] = info; list[i] = info;
} }
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlBookInfoArray(list)); MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlBookInfoArray(list));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
//----------- get values ------------------------------- //----------- get values -------------------------------
int _stdcall getCommandType(int expertHandle, int* res) int _stdcall getCommandType(int expertHandle, int* res)
{ {
try try
{ {
*res = MtServerInstance::GetInstance()->GetCommandType(expertHandle); *res = MtServerInstance::GetInstance()->GetCommandType(expertHandle);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getCommandType(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getCommandType(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall getIntValue(int expertHandle, int paramIndex, int* res) int _stdcall getIntValue(int expertHandle, int paramIndex, int* res)
{ {
try try
{ {
*res = (int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex); *res = (int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getIntValue(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getIntValue(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res) int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res)
{ {
try try
{ {
*res = (double)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex); *res = (double)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getDoubleValue(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getDoubleValue(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res) int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res)
{ {
try try
{ {
convertSystemString(res, (String^)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex)); convertSystemString(res, (String^)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getStringValue(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getStringValue(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res) int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res)
{ {
try try
{ {
*res = (unsigned long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex); *res = (unsigned long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getULongValue(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getULongValue(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res) int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res)
{ {
try try
{ {
*res = (long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex); *res = (long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getLongValue(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getLongValue(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res) int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res)
{ {
try try
{ {
bool val = (bool)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex); bool val = (bool)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = val == true ? 1 : 0; *res = val == true ? 1 : 0;
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getBooleanValue(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getBooleanValue(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int* res) int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int* res)
{ {
try try
{ {
*res = (unsigned int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex); *res = (unsigned int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
Debug::WriteLine("[ERROR] MT5Connector:getUIntValue(): " + e->Message); Debug::WriteLine("[ERROR] MT5Connector:getUIntValue(): " + e->Message);
return 0; return 0;
} }
return 1; return 1;
} }
+9 -9
View File
@@ -9,16 +9,16 @@ using namespace MTApiService;
ref class MT5Handler: IMetaTraderHandler ref class MT5Handler: IMetaTraderHandler
{ {
public: public:
MT5Handler() MT5Handler()
{ {
msgId = WM_USER + 4096; msgId = WM_TIMER;
} }
virtual void SendTickToMetaTrader(int handle) virtual void SendTickToMetaTrader(int handle)
{ {
PostMessage((HWND)handle, msgId, 0x00000011, 0); PostMessage((HWND)handle, msgId, 0, 0);
} }
private: private:
unsigned int msgId; unsigned int msgId;
}; };
-2
View File
@@ -11,13 +11,11 @@ ref class MT4Handler: IMetaTraderHandler
public: public:
MT4Handler() MT4Handler()
{ {
//msgId = RegisterWindowMessage("MetaTrader4_Internal_Message");
msgId = WM_TIMER; msgId = WM_TIMER;
} }
virtual void SendTickToMetaTrader(int handle) virtual void SendTickToMetaTrader(int handle)
{ {
//PostMessage((HWND)handle, msgId, 2, 1);
PostMessage((HWND)handle, msgId, 0, 0); PostMessage((HWND)handle, msgId, 0, 0);
} }
+1 -1
View File
@@ -12,7 +12,7 @@
<?define PlatformSystemFolder = "SystemFolder" ?> <?define PlatformSystemFolder = "SystemFolder" ?>
<?endif ?> <?endif ?>
<?define ProductVersion="1.0.9" ?> <?define ProductVersion="1.0.10" ?>
<?define Manufacturer="DW"?> <?define Manufacturer="DW"?>
<?define ProductPath="..\build\products\$(var.Configuration)\"?> <?define ProductPath="..\build\products\$(var.Configuration)\"?>