Compare commits

...

136 Commits

Author SHA1 Message Date
vdemydiuk f01ec01a5f Disable debug loging in MtApi.ex5 2018-06-06 15:11:56 +03:00
vdemydiuk 0c38d37559 Issue #107: Added function PositionCloseAll 2018-06-06 14:24:39 +03:00
vdemydiuk 897892dc89 Issue #122: Added event OnLockTicksEvent (MT5) 2018-06-06 12:46:24 +03:00
vdemydiuk 1a5882b75a Issue #122: Implemented UnlockTicks function in MtApi (MT5) 2018-06-05 19:19:35 +03:00
vdemydiuk 0f717f1cb7 Issue #119: Added out parameter MqlTradeResult to function PositionClose 2018-06-04 17:48:14 +03:00
vdemydiuk 5d78ad5067 Issue #120: set field 'Symbol' as optional in MqlTradeRequest (MT5) 2018-06-04 15:36:35 +03:00
vdemydiuk 6c45f28a05 Issue #121: Added original MtTime field to MqlRates (MT5) 2018-06-04 15:04:12 +03:00
vdemydiuk ca3c0e735f Issue #110: Implemented function for working with global variables (MT5) 2018-06-04 13:53:55 +03:00
vdemydiuk f71151104b Issue #111: Added enum value SYMBOL_VISIBLE 2018-05-08 19:07:52 +03:00
vdemydiuk 28816a75ac Issue #113: Changed extension of logging files to *.log 2018-05-08 16:44:57 +03:00
vdemydiuk 6023bffed6 Issue #106: Extended structure Mt5Quote with fields from MqlTick (volume, last, time) 2018-05-08 14:53:31 +03:00
vdemydiuk fd34f009cd Started version 1.0.19 (MT5) 2018-05-08 14:50:25 +03:00
Vyacheslav Demidyuk 1bb2b65cdf Merge pull request #115 from CVasquezG/master
Updated README
2018-04-02 16:27:58 +03:00
CVasquezG 37e8275465 Updated README
Changes made to the README file to be more formal.
I am doing this as a university assignment where I am required to improve documentation in the open source community.  I hope changes suggested in this commit are useful for your project.
2018-03-31 14:08:20 -07:00
vdemydiuk 52ca4fae1e MtApi5.ex5: Update version to 1.5. Disable debug logging 2018-03-27 11:25:22 +03:00
vdemydiuk 6b327e017a Removed unnecessary Windows Operations from MtApi5 code (MT5) 2018-03-27 11:11:33 +03:00
vdemydiuk 10a758bd93 Updated test application (MT5) to perform testing functions ChartIndicatorAdd, ChartIndicatorGet 2018-03-27 10:22:16 +03:00
vdemydiuk 4a9642b60c Issue #109: Fixed typo 'Magic' to 'Order' in MQL function JsonToMqlTradeRequest 2018-03-26 18:06:39 +03:00
vdemydiuk 6ba6496e46 Implemented functions ChartIndicatorAdd and ChartIndicatorGet 2018-03-24 21:45:35 +02:00
vdemydiuk 1ffbba5ee3 Updated test application (MT5) to perform testing functions ChartNavigate, ChartIndicatorDelete, ChartIndicatorName, ChartIndicatorsTotal, ChartWindowOnDropped, ChartPriceOnDropped, ChartTimeOnDropped, ChartXOnDropped, ChartYOnDropped, ChartSetSymbolPeriod, ChartScreenShot 2018-03-24 19:08:40 +02:00
vdemydiuk 8cdfd6fb91 Updated test application (MT5) to perform testing function ChartGetDouble and ChartGetInteger 2018-03-19 19:10:51 +02:00
vdemydiuk 7c3ddbabac Updated test application (MT5) to perform testing function ChartSetInteger and ChartSetString 2018-03-19 18:58:12 +02:00
vdemydiuk 83e0145a3a Updated test application (MT5) to perform testing function ChartPeriod and ChartSetDouble 2018-03-19 18:39:15 +02:00
vdemydiuk f17c7cd554 Updated test application (MT5) to perform testing function ChartWindowFind and ChartClose 2018-03-19 17:23:16 +02:00
vdemydiuk 4aefdd554b Updated test application (MT5) to perform testing function ChartId and ChartRedraw 2018-03-19 16:23:55 +02:00
vdemydiuk 820ed9a631 Refactored UI test client (MT5) 2018-03-19 15:10:09 +02:00
vdemydiuk 95c55e90be Added field ExpertHandle into class Mt5Quote 2018-03-19 15:09:02 +02:00
vdemydiuk 486a1979a6 Implemented functions ChartIndicatorName, ChartIndicatorsTotal, ChartWindowOnDropped, ChartPriceOnDropped, ChartTimeOnDropped, ChartXOnDropped, ChartYOnDropped, ChartSetSymbolPeriod, ChartScreenShot (MT5) 2018-03-15 17:44:53 +02:00
vdemydiuk faef5f7d18 Implemented function ChartIndicatorDelete (MT5) 2018-03-15 13:15:50 +02:00
vdemydiuk bd45c45fa1 Implemented function ChartNavigate (MT5) 2018-03-15 12:55:46 +02:00
vdemydiuk 29be184136 Implemented functions ChartGetDouble, ChartGetInteger (MT5) 2018-03-15 11:20:20 +02:00
vdemydiuk 9bfda95cf7 Implemented functions ChartSetDouble, ChartSetInteger, ChartSetString (MT5) 2018-03-14 19:53:53 +02:00
vdemydiuk 24b881d8a0 Implemented function ChartPeriod (MT5) 2018-03-14 19:16:29 +02:00
vdemydiuk 07dd83f890 Implemented functions ChartId, ChartRedraw, ChartWindowFind, ChartClose (MT5) 2018-03-14 18:10:44 +02:00
vdemydiuk 9afd30e463 Implemented function Alert (MT5) 2018-03-13 18:24:40 +02:00
vdemydiuk 16f454ca61 Implemented functions ChartTimePriceToXY, ChartXYToTimePrice (MT5) 2018-03-13 17:28:21 +02:00
vdemydiuk f3a3a582fd Issue #100: update test application for testing function SymbolInfoString (MT5) 2018-03-13 11:40:16 +02:00
vdemydiuk 93aaae86ed Issue #100: implemented second function SymbolInfoString (MT5) 2018-03-13 11:20:55 +02:00
Vyacheslav Demidyuk bce68fd168 Merge pull request #104 from Janderson/master
TerminalInfo Commands and ChartTemplate Commands
2018-03-13 10:54:16 +02:00
Janderson 0812229538 Chart Commands:
- ChartSaveTemplate Implemented
2018-03-12 23:08:04 -03:00
Janderson d0fa4af1d0 - Bug fix - when click in chartApplyTemplateButton, store template file in right place 2018-03-12 22:44:08 -03:00
Janderson 8eb4bcfabe Commands to handle with Terminal:
- TerminalInfoDoublePropertyId
- TerminalInfoIntegerPropertyId
- TerminalInfoStringPropertyId
2018-03-12 22:37:06 -03:00
Vyacheslav Demidyuk 9ea58354be Merge pull request #103 from Janderson/master
Missing function to mql5
2018-03-12 16:49:21 +02:00
Janderson FFerreira 02774d7328 Merge branch 'mt5_1_0_18' into master 2018-03-12 11:34:00 -03:00
Janderson FFerreira cbff71f8d0 - Correction of Test Client
- Missing codes in mtapi5.mq5
2018-03-12 11:17:12 -03:00
Janderson FFerreira 951a91976c - missing mql5 file 2018-03-11 19:56:28 -03:00
Janderson FFerreira 6a37826486 - Add some commands to handle with Chart to MT5 api
- Add some commands to handle with windows to MT5 api
2018-03-11 19:26:25 -03:00
vdemydiuk cab2de6d24 Issue #100: implemented functions GetLastError, ResetLastError() in MtApi (MT5) 2018-03-09 19:18:54 +02:00
vdemydiuk ec6c71607b Issue #96: Implemented function PositionGetTicket in MtApi (MT5) 2018-03-08 17:45:22 +02:00
vdemydiuk 0a39b69b15 Issue #95: Added default constructors to classes MqlBookInfo, MqlTradeCheckResult 2018-03-08 16:22:37 +02:00
vdemydiuk fe94ec21de Issue #102: fixed long type of result in function SeriesInfoInteger 2018-03-08 15:31:02 +02:00
vdemydiuk 34c78c73c0 Started version 1.0.18 (MT5) 2018-03-08 15:26:29 +02:00
vdemydiuk d7b8ef894c Issue #93: Fixed typo Cction (Action) in MtApi5.mq5 2018-03-02 13:22:40 +02:00
vdemydiuk 7f33cebce1 MtApi5: Set version 1.0.17 2018-03-02 12:21:54 +02:00
vdemydiuk 84740787d5 Issue #94: Added event handler OnBookEvent (MT5). 2018-03-02 11:43:03 +02:00
vdemydiuk ad6bad5187 Issue #93: Added event OnTradeTransaction. Udpated json.mqh to fix JSONNumber for correct serialization zero integer value". 2018-03-01 11:20:25 +02:00
vdemydiuk 0086b02bc8 Issue #92: Updated test application (MT5) to use functions IndicatorCreate and IndicatorRelease 2018-02-27 18:26:37 +02:00
vdemydiuk f7e06c1570 Issue #92: Added functions IndicatorCreate and IndicatorRelease 2018-02-27 09:49:26 +02:00
vdemydiuk c86a3a3752 Issue #91: Added MarketBookGetRequest to perform function MarketBookGet (MT5) 2018-02-21 14:43:25 +02:00
vdemydiuk be8a17c0fd Issue #88: Activate execute commands in tester mode (MT5) 2018-02-19 19:21:29 +02:00
vdemydiuk 5c6751de9b Issue #90: Added time functions: TimeCurrent, TimeTradeServer, TimeLocal, TimeGMT 2018-02-19 18:48:31 +02:00
vdemydiuk 83776f8b7a Minor refactoring to remote redundant code 2018-02-19 17:12:26 +02:00
vdemydiuk f1c1df1e00 Issue #89: Changed function OrderCheck to use json request/response 2018-02-19 17:02:19 +02:00
vdemydiuk d6640300f5 Issue #89: Changed function PositionOpen to use json request/response 2018-02-19 15:54:03 +02:00
vdemydiuk c9c188f697 Minor refactoring to remove code syle warnings 2018-02-19 13:37:43 +02:00
vdemydiuk 3a4f561836 Issue #87: Added event QuoteUpdate to MtApi5Client (MT5) for compatibility with MATLAB 2018-02-19 11:49:52 +02:00
vdemydiuk bdb30edee3 Issue #82: Responsed moved to Request folder 2018-02-19 11:27:07 +02:00
vdemydiuk 29f501b055 Issue #82: Refactored request responses (MtAp5). Added iCustom functions with string and boolean parameters. Added button iCustom in test application (MT5). 2018-02-19 11:07:37 +02:00
vdemydiuk 521d7ea2c0 Issue #82: Disabled debug mode in MtApi5.ex5. Updated test client to send order with values Expiration and Comment 2018-02-18 20:24:27 +02:00
DW 0e5bb40a6f Issue #82: Refactored MQL5 expert to use json in function OrderSend 2018-02-17 00:10:10 +02:00
vdemydiuk 14079dc3c1 Issue #82: Added stub class OrderSendRequest 2018-02-15 20:32:22 +02:00
vdemydiuk 3600a86971 MtApiService version 1.0.29. Added log wrapper class MtLog 2018-02-15 17:37:08 +02:00
vdemydiuk 83e62fbff7 Started version 1.0.16 (MT5) 2018-02-15 17:33:02 +02:00
vdemydiuk 5c96aeb2fd Issue #81: Added function TimeGMT into MtApi (MT4) 2018-02-13 19:02:08 +02:00
vdemydiuk a238e5eb36 Issue #80: Fixed wrong condition on fetch first parameter in function Execute_TerminalInfoString 2018-02-13 18:35:40 +02:00
vdemydiuk 11fd5b7527 Started version 1.0.40 (MT4) 2018-02-13 18:33:11 +02:00
vdemydiuk cbe75cfbf6 Issue #83: Added command button HistoryDealMethods to check functions related to the issue 2018-02-08 18:04:15 +02:00
vdemydiuk 9581431a9f Issue #84: Fixed bug in function HistoryOrderGetInteger, there was wrong return value type 2018-02-04 14:39:09 +02:00
vdemydiuk acf0c12531 MT5: started version 1.0.15 2018-02-04 14:02:41 +02:00
DW 1eccda9b2c Version MtApi4 1.0.39 2018-01-16 16:11:33 +02:00
DW fd4aac7c32 Issie #73: added wrapped function getBooleanValueW into MtApi.mq4. Issue #76: added precompiled value __DEBUG_LOG__ into MtApi.mq4 to disable logging in release verion 2018-01-16 16:06:21 +02:00
DW 36c90c8481 Updated test application (MT5): added test functions HistoryDealGetDouble, HistoryDealGetInteger, HistoryDealGetString 2018-01-11 15:28:57 +02:00
DW fefa451371 Issue #39: Added indicator functions on MQL side (MtApi MT5) 2018-01-10 19:13:31 +02:00
DW 1c57f88cb1 Issue #72: Fixed bug with serialization of parameters in functions HistoryDealGetInteger, HistoryDealGetString, HistoryDealGetDouble 2017-11-27 18:16:35 +02:00
DW 08ba45c65f Issue #39: Added indicator functions on C# side (MtApi MT5) 2017-11-27 18:09:54 +02:00
DW b8314e9ed7 MtApi5: add waiting incoming connection on MT5 side in backtesting mode 2017-11-15 18:16:23 +02:00
DW 9587b10c8c MtApi5 version 1.0.14 2017-11-15 18:15:34 +02:00
DW b838084ba2 Issue #14: Updated test application for using function PositionOpen with MqlTradeResult 2017-09-29 19:05:06 +03:00
DW cd24891022 Issue #14: Added function PositionOpen which returns MqlTradeResult 2017-09-29 18:27:36 +03:00
DW add69a4c03 Issue #41: Complete object functions on MQL side 2017-09-29 17:39:18 +03:00
DW 5a3407e47c Issue #41: Refactored MtApi5.mq5 - removed unnecessary variables 2017-09-29 15:48:46 +03:00
DW ce8cfbbb70 Issue #41: Refactored MtApi5.mq5 2017-09-29 15:34:35 +03:00
DW 8470bbd5cc Issue #41: Complete object functions in client side (MT5) 2017-09-27 18:36:26 +03:00
DW 5c7ae748a5 Issue #41: Added Object Properties enums: ENUM_OBJECT_PROPERTY_INTEGER, ENUM_OBJECT_PROPERTY_STRING, ENUM_BORDER_TYPE, ENUM_ALIGN_MODE 2017-09-27 17:45:09 +03:00
DW 7abb4d3b5e Issue #41: Partialy implemented object functions on client side 2017-09-27 15:38:54 +03:00
DW 486c42685a Issue #41: Added Object Types enum 2017-09-26 18:37:50 +03:00
DW f41ab37b6f Set version 1.0.13 of MtApi (MT5) 2017-09-26 17:27:06 +03:00
Vyacheslav Demidyuk 9e129fb6e2 Merge pull request #64 from Tr4Dr/master
Fixes for the OrderSend function [MT5]
2017-09-25 12:41:35 +03:00
Tr4Dr f7b00a8d88 Added null check to convertSystemString [MT5]
Whithout this fix, the OrderSend method crashing if we doesn't set the "request.Comment" property.
2017-09-18 14:55:03 +02:00
Tr4Dr a7cb14de25 Updated MqlTradeRequest [MT5] 2017-09-18 02:05:22 +02:00
Tr4Dr f50925c8d3 Changed wcslen to wcsnlen [MT5]
Maximum character length set to 1000 based on preinit() MQL5 function. This value must be kept synchronized with MQL side.
2017-09-17 22:35:26 +02:00
Tr4Dr e29a11de68 Changed type of '\0' literal to wchar_t [MT5] 2017-09-17 22:19:09 +02:00
Tr4Dr 12141775f3 Fixed type casting to __int64 [MT5]
long long type should be an alternative.
2017-09-17 22:05:56 +02:00
Tr4Dr b6d24b8aa9 Merge pull request #2 from vdemydiuk/master
Update from original
2017-09-16 22:01:19 +02:00
DW 7175fae18c Fixed WIX error: ICE Internal Error 100. API Returned: 1615. 2017-09-08 17:07:53 +03:00
DW 3c4d8d52ca Revert version mtapi (MT5) to 1.0.12 2017-09-08 16:30:39 +03:00
DW 6873363d41 Fixed build of MT5 test client 2017-09-08 16:07:41 +03:00
DW 947599327a MtApi5 version 1.0.13 2017-09-08 13:05:01 +03:00
DW 5645902a48 Merge branch 'master' into mt5_1_0_13 2017-09-08 12:45:31 +03:00
DW c82787473f Issue #16: Added Mt5Expert into MTApiService. Refactored MT5Connector 2017-09-08 12:44:14 +03:00
Vyacheslav Demidyuk c213fb709a Merge pull request #62 from Tr4Dr/master
Fixed the type of Deviation property in MqlTradeRequest (MT5)
2017-09-08 12:38:29 +03:00
Tr4Dr 2ac29dc871 Fixed the type of Deviation property in MqlTradeRequest (MT5) 2017-09-07 20:08:01 +02:00
DW 1f72b2b790 Refactored MTApiService and connectors projects 2017-09-07 17:46:25 +03:00
Vyacheslav Demidyuk 3a62ff56d7 Merge pull request #61 from Tr4Dr/master
Updated PositionClose function and a fixed warning (MT5)
2017-09-07 12:23:34 +03:00
Unknown d25fe529b4 Fixed warning in function CreateErrorResponse (MT5)
Declaration of 'message' hides global declaration in MtApi5.mq5
2017-09-07 00:21:12 +02:00
Unknown 15538e81f4 Updated PositionClose function (MT5)
Type of the ticket argument changed to ulong, added optional argument: deviation
2017-09-07 00:06:59 +02:00
Tr4Dr a33be3c764 Merge pull request #1 from vdemydiuk/master
Bringing fork up to date
2017-09-06 23:48:13 +02:00
DW 023fe8c7c9 Disable code to print event payload in MQL code (MT4) 2017-09-06 11:47:45 +03:00
DW b77516e324 Issue #59: Added event OnChartEvent into MtApi (MT4) 2017-09-05 18:34:26 +03:00
DW 4b48423c3f Issue #57: Added function PositionSelectByTicket into MQL code 2017-09-04 13:08:30 +03:00
DW 9800177b08 Issue #57: Added function PositionSelectByTicket into C# code 2017-08-29 17:40:23 +03:00
Vyacheslav Demidyuk a33d4a4594 Merge pull request #58 from Tr4Dr/master
Refactored and updated enumerations
2017-08-28 13:56:44 +03:00
Unknown 29722f362d Added Position and PositionBy properties to MqlTradeRequest 2017-08-25 15:32:24 +02:00
Unknown e072343fe1 Missing break after PositionGetSymbol 2017-08-25 15:12:41 +02:00
Unknown acb0c20ca8 Missing break after PositionGetDouble 2017-08-25 15:00:24 +02:00
Unknown 83543fee88 Refactored and updated enumerations 2017-08-25 01:31:57 +02:00
DW 3ce6b042de Added files into MtApi.proj 2017-08-21 15:56:21 +03:00
DW 9dd770e768 Fixed small errors in MQL part of chart operations 2017-08-21 15:42:10 +03:00
DW abb8b8afaa Added enums for chart properties. Fixed some mistakes in C# code of Chart Operations 2017-08-21 13:57:38 +03:00
DW 1d6569caa8 Issue #53: Complete add chart operation functions in expert (MQL part) 2017-08-18 18:56:00 +03:00
DW 441a3cb8de Merge with branch auth 2017-08-15 16:42:51 +03:00
DW 443f5c982c Issue #53: Complete chart operation functions into MtApi (client side) 2017-08-15 14:34:41 +03:00
DW 515a12ab15 Added function ChangeAccount 2017-08-12 01:31:36 +03:00
DW 84b00b605a Issue #53: Added some chart operation functions into MtApi (client side) 2017-08-11 23:33:30 +03:00
DW 10e267d031 Fixed bug in function iBarShift 2017-07-20 17:55:29 +03:00
DW abcd489367 Started version 1.0.37 2017-06-21 17:41:10 +03:00
96 changed files with 13532 additions and 2839 deletions
+1 -3
View File
@@ -35,6 +35,4 @@ using namespace System::Security::Permissions;
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
[assembly:CLSCompliantAttribute(true)];
+138 -325
View File
@@ -6,14 +6,15 @@
#include "MT5Handler.h"
#include "Windows.h"
#include < vcclr.h >
#include <vcclr.h>
#include <functional>
using namespace System;
using namespace MTApiService;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace System::Collections::Generic;
using namespace System::Diagnostics;
using namespace System::Security::Cryptography;
using namespace System::Security;
@@ -50,277 +51,162 @@ public struct CMqlBookInfo
void convertSystemString(wchar_t* dest, String^ src)
{
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
memcpy(dest, wch, wcslen(wch) * sizeof(wchar_t));
dest[wcslen(wch)] = '\0';
if (src != nullptr) {
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
memcpy(dest, wch, wcsnlen(wch, 1000) * sizeof(wchar_t));
dest[wcsnlen(wch, 1000)] = L'\0';
}
else
{
dest[0] = L'\0';
}
}
bool VerifySignature(System::String^ inputData, System::String^ signature, System::String^ publicKey)
{
bool verifyResult = false;
#define _DLLAPI extern "C" __declspec(dllexport)
template <typename T> T Execute(std::function<T()> func, wchar_t* err, T default_value)
{
T result = default_value;
try
{
DSACryptoServiceProvider^ dsa = gcnew DSACryptoServiceProvider();
dsa->FromXmlString(publicKey);
array<System::Byte>^ data = UTF8Encoding::ASCII->GetBytes(inputData);
array<System::Byte>^ signatureData = Convert::FromBase64String(signature);
verifyResult = dsa->VerifyData(data, signatureData);
}
catch(Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:VerifySignature(): failed. " + e->Message);
verifyResult = false;
}
return verifyResult;
}
bool g_IsVerified = true;
void _stdcall verify(int isDemo, wchar_t* accountName, long accountNumber)
{
if (isDemo != 0)
{
g_IsVerified = true;
return;
}
System::String^ signature = MtRegistryManager::ReadSignatureKey(gcnew String(accountName), accountNumber.ToString());
Resources::ResourceManager^ rm = gcnew Resources::ResourceManager(L"MT5Connector.cl", Assembly::GetExecutingAssembly());
System::String^ inputData = gcnew System::String(accountName);
inputData += accountNumber.ToString();
System::String^ publicKey = rm->GetString(L"cl");
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)
{
if (g_IsVerified == false)
{
System::String^ errorVerified = "Verification is failed!\nPlease contact with support.";
convertSystemString(err, errorVerified);
Debug::WriteLine("[ERROR] MT5Connector:initExpert(): not verified");
return 0;
}
try
{
MT5Handler^ mtHander = gcnew MT5Handler();
MtAdapter::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHander);
result = func();
}
catch (Exception^ e)
{
convertSystemString(err, e->Message);
Debug::WriteLine("[ERROR] MT5Connector:initExpert(): " + e->Message);
return 0;
}
return 1;
return result;
}
int _stdcall deinitExpert(int expertHandle, wchar_t* err)
_DLLAPI int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, int isTestMode, wchar_t* err)
{
try
{
MtAdapter::GetInstance()->DeinitExpert(expertHandle);
}
catch (Exception^ e)
{
convertSystemString(err, e->Message);
Debug::WriteLine("[ERROR] MT5Connector:deinitExpert(): " + e->Message);
return 0;
}
return 1;
return Execute<int>([&expertHandle, &port, symbol, &bid, &ask, &isTestMode]() {
bool isTesting = (isTestMode != 0) ? true : false;
auto expert = gcnew Mt5Expert(expertHandle, gcnew String(symbol), bid, ask, gcnew MT5Handler(), isTesting);
MtAdapter::GetInstance()->AddExpert(port, expert);
return 1;
}, err, 0);
}
int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err)
_DLLAPI int _stdcall deinitExpert(int expertHandle, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle]() {
MtAdapter::GetInstance()->RemoveExpert(expertHandle);
return 1;
}, err, 0);
}
_DLLAPI int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err)
{
return Execute<int>([&expertHandle, symbol, &bid, &ask]() {
MtAdapter::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
}
catch (Exception^ e)
{
convertSystemString(err, e->Message);
Debug::WriteLine("[ERROR] MT5Connector:updateQuote(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendIntResponse(int expertHandle, int response)
_DLLAPI bool _stdcall sendEvent(int expertHandle, int eventType, wchar_t* payload, wchar_t* err)
{
try
{
return Execute<bool>([&expertHandle, &eventType, payload]() {
MtAdapter::GetInstance()->SendEvent(expertHandle, eventType, gcnew String(payload));
return true;
}, err, false);
}
_DLLAPI int _stdcall sendIntResponse(int expertHandle, int response, wchar_t* err)
{
return Execute<int>([&expertHandle, &response]() {
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendIntResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendLongResponse(int expertHandle, __int64 response)
_DLLAPI int _stdcall sendLongResponse(int expertHandle, __int64 response, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &response]() {
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendULongResponse(int expertHandle, unsigned __int64 response)
_DLLAPI int _stdcall sendULongResponse(int expertHandle, unsigned __int64 response, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &response]() {
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseULong(response));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendBooleanResponse(int expertHandle, int response)
_DLLAPI int _stdcall sendBooleanResponse(int expertHandle, int response, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &response]() {
bool value = (response != 0) ? true : false;
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendBooleanResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendDoubleResponse(int expertHandle, double response)
_DLLAPI int _stdcall sendDoubleResponse(int expertHandle, double response, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &response]() {
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendDoubleResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendStringResponse(int expertHandle, wchar_t* response)
_DLLAPI int _stdcall sendStringResponse(int expertHandle, wchar_t* response, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, response]() {
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendStringResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendVoidResponse(int expertHandle)
_DLLAPI int _stdcall sendVoidResponse(int expertHandle, wchar_t* err)
{
try
{
MtAdapter::GetInstance()->SendResponse(expertHandle, nullptr);
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendVoidResponse(): " + e->Message);
return 0;
}
return 1;
return Execute<int>([&expertHandle]() {
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseObject(nullptr));
return 1;
}, err, 0);
}
int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size)
_DLLAPI int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, values, &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];
}
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendDoubleArrayResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size)
_DLLAPI int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, values, &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];
}
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendIntArrayResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendLongArrayResponse(int expertHandle, __int64* values, int size)
_DLLAPI int _stdcall sendLongArrayResponse(int expertHandle, __int64* values, int size, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, values, &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];
}
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLongArray(list));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendLongArrayResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int size)
_DLLAPI int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int size, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, values, &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();
rates->time = values[i].time;
@@ -331,180 +217,107 @@ int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int
rates->tick_volume = values[i].tick_volume;
rates->spread = values[i].spread;
rates->real_volume = values[i].real_volume;
list[i] = rates;
}
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlRatesArray(list));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendMqlTickResponse(int expertHandle, CMqlTick* response, int size)
_DLLAPI int _stdcall sendMqlTickResponse(int expertHandle, CMqlTick* response, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, response]() {
MtMqlTick^ mtResponse = gcnew MtMqlTick();
mtResponse->time = response->time;
mtResponse->bid = response->bid;
mtResponse->ask = response->ask;
mtResponse->last = response->last;
mtResponse->volume = response->volume;
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlTick(mtResponse));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendMqlTickResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall sendMqlBookInfoArrayResponse(int expertHandle, CMqlBookInfo values[], int size)
_DLLAPI int _stdcall sendMqlBookInfoArrayResponse(int expertHandle, CMqlBookInfo values[], int size, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, values, &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();
info->type = values[i].type;
info->price = values[i].price;
info->volume = values[i].volume;
list[i] = info;
}
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlBookInfoArray(list));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
//----------- get values -------------------------------
int _stdcall getCommandType(int expertHandle, int* res)
_DLLAPI int _stdcall getCommandType(int expertHandle, int* res, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, res]() {
*res = MtAdapter::GetInstance()->GetCommandType(expertHandle);
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getCommandType(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall getIntValue(int expertHandle, int paramIndex, int* res)
_DLLAPI int _stdcall getIntValue(int expertHandle, int paramIndex, int* res, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &paramIndex, res]() {
*res = (int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getIntValue(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res)
_DLLAPI int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &paramIndex, res]() {
*res = (double)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getDoubleValue(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res)
_DLLAPI int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &paramIndex, res]() {
convertSystemString(res, (String^)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getStringValue(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res)
_DLLAPI int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res, wchar_t* err)
{
try
{
*res = (unsigned long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getULongValue(): " + e->Message);
return 0;
}
return 1;
return Execute<int>([&expertHandle, &paramIndex, res]() {
*res = (unsigned __int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
return 1;
}, err, 0);
}
int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res)
_DLLAPI int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res, wchar_t* err)
{
try
{
*res = (long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getLongValue(): " + e->Message);
return 0;
}
return 1;
return Execute<int>([&expertHandle, &paramIndex, res]() {
*res = (__int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
return 1;
}, err, 0);
}
int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res)
_DLLAPI int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &paramIndex, res]() {
bool val = (bool)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = val == true ? 1 : 0;
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getBooleanValue(): " + e->Message);
return 0;
}
return 1;
return 1;
}, err, 0);
}
int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int* res)
_DLLAPI int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int* res, wchar_t* err)
{
try
{
return Execute<int>([&expertHandle, &paramIndex, res]() {
*res = (unsigned int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
Debug::WriteLine("[ERROR] MT5Connector:getUIntValue(): " + e->Message);
return 0;
}
return 1;
}
return 1;
}, err, 0);
}
-27
View File
@@ -1,27 +0,0 @@
LIBRARY MT5Connector
EXPORTS initExpert
deinitExpert
updateQuote
sendIntResponse
sendBooleanResponse
sendDoubleResponse
sendStringResponse
sendVoidResponse
sendDoubleArrayResponse
sendIntArrayResponse
sendLongArrayResponse
sendMqlRatesArrayResponse
sendLongResponse
sendULongResponse
sendMqlTickResponse
sendMqlBookInfoArrayResponse
getCommandType
getIntValue
getUIntValue
getDoubleValue
getStringValue
getLongValue
getULongValue
getBooleanValue
verify
-5
View File
@@ -95,7 +95,6 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>user32.lib</AdditionalDependencies>
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -108,7 +107,6 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -120,7 +118,6 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -132,7 +129,6 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -157,7 +153,6 @@
</ItemGroup>
<ItemGroup>
<None Include="app.ico" />
<None Include="MT5Connector.def" />
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
@@ -44,9 +44,6 @@
<None Include="app.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="MT5Connector.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc">
+1 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MTApiService
namespace MTApiService
{
public interface IMetaTraderHandler
{
+53 -1
View File
@@ -8,9 +8,53 @@ using log4net.Repository.Hierarchy;
namespace MTApiService
{
public class MtLog
{
#region ctor
internal MtLog(Type type)
{
_log = LogManager.GetLogger(type);
}
#endregion
#region Public
public void Debug(object message)
{
_log.Debug(message);
}
public void Error(object message)
{
_log.Error(message);
}
public void Fatal(object message)
{
_log.Fatal(message);
}
public void Info(object message)
{
_log.Info(message);
}
public void Warn(object message)
{
_log.Warn(message);
}
#endregion
#region Private
private readonly ILog _log;
#endregion
}
public class LogConfigurator
{
private const string LogFileNameExtension = "txt";
private const string LogFileNameExtension = "log";
public static void Setup(string profileName)
{
@@ -48,5 +92,13 @@ namespace MTApiService
#endif
hierarchy.Configured = true;
}
public static MtLog GetLogger(Type type)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
return new MtLog(type);
}
}
}
+1
View File
@@ -64,6 +64,7 @@
<Compile Include="IMetaTraderHandler.cs" />
<Compile Include="ITaskExecutor.cs" />
<Compile Include="LogConfigurator.cs" />
<Compile Include="Mt5Expert.cs" />
<Compile Include="MtCommandEventArgs.cs" />
<Compile Include="IDisposableChannel.cs" />
<Compile Include="IMtApiServer.cs" />
+77
View File
@@ -0,0 +1,77 @@
using log4net;
namespace MTApiService
{
public class Mt5Expert : MtExpert
{
private static readonly ILog Log = LogManager.GetLogger(typeof(Mt5Expert));
private const int StopExpertInterval = 2000; // 2 sec for testing mode
private System.Timers.Timer _stopTimer;
public Mt5Expert(int handle, string symbol, double bid, double ask, IMetaTraderHandler mtHandler, bool isTestMode) :
base(handle, symbol, bid, ask, mtHandler)
{
IsTestMode = isTestMode;
}
public bool IsTestMode { get; }
public override int GetCommandType()
{
Log.Debug("GetCommandType: called.");
if (IsTestMode)
{
ResetTestModeTimer();
}
return base.GetCommandType();
}
public override void SendEvent(MtEvent mtEvent)
{
Log.DebugFormat("SendEvent: begin. event = {0}", mtEvent);
if (IsTestMode)
{
if (_stopTimer == null)
{
_stopTimer = new System.Timers.Timer
{
Interval = StopExpertInterval,
AutoReset = false
};
_stopTimer.Elapsed += _stopTimer_Elapsed;
}
}
base.SendEvent(mtEvent);
Log.Debug("SendEvent: end.");
}
private void _stopTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Log.Debug("_stopTimer_Elapsed: begin.");
Log.Warn("Mt5Expert has received new tick during 2 sec in testing mode. The possible cause: user has stopped the tester manually in MetaTrader 5.");
Deinit();
_stopTimer.Elapsed -= _stopTimer_Elapsed;
_stopTimer = null;
Log.Debug("_stopTimer_Elapsed: end.");
}
private void ResetTestModeTimer()
{
if (_stopTimer == null)
return;
//reset timer
_stopTimer.Stop();
_stopTimer.Start();
}
}
}
+39 -16
View File
@@ -36,12 +36,12 @@ namespace MTApiService
#region Public Methods
public void InitExpert(int expertHandle, int port, string symbol, double bid, double ask, IMetaTraderHandler mtHandler)
public void AddExpert(int port, MtExpert expert)
{
if (mtHandler == null)
throw new ArgumentNullException(nameof(mtHandler));
if (expert == null)
throw new ArgumentNullException(nameof(expert));
Log.InfoFormat("InitExpert: begin. symbol = {0}, expertHandle = {1}, port = {2}", symbol, expertHandle, port);
Log.InfoFormat("AddExpert: begin. expert = {0}", expert);
MtServer server;
lock (_servers)
@@ -60,21 +60,20 @@ namespace MTApiService
}
}
var expert = new MtExpert(expertHandle, new MtQuote { Instrument = symbol, Bid = bid, Ask = ask, ExpertHandle = expertHandle }, mtHandler);
lock (_experts)
{
_experts[expert.Handle] = expert;
}
server.AddExpert(expert);
expert.Deinited += ExpertOnDeinited;
Log.Info("InitExpert: end");
Log.Info("AddExpert: end");
}
public void DeinitExpert(int expertHandle)
public void RemoveExpert(int expertHandle)
{
Log.InfoFormat("DeinitExpert: begin. expertHandle = {0}", expertHandle);
Log.InfoFormat("RemoveExpert: begin. expertHandle = {0}", expertHandle);
MtExpert expert = null;
@@ -83,7 +82,6 @@ namespace MTApiService
if (_experts.ContainsKey(expertHandle))
{
expert = _experts[expertHandle];
_experts.Remove(expertHandle);
}
}
@@ -93,15 +91,15 @@ namespace MTApiService
}
else
{
Log.WarnFormat("DeinitExpert: expert with id {0} has not been found.", expertHandle);
Log.WarnFormat("RemoveExpert: expert with id {0} has not been found.", expertHandle);
}
Log.Info("DeinitExpert: end");
Log.Info("RemoveExpert: end");
}
public void SendQuote(int expertHandle, string symbol, double bid, double ask)
{
Log.DebugFormat("SendQuote: begin. symbol = {0}, bid = {1}, ask = {2}", symbol, bid, ask);
Log.DebugFormat("UpdateQuote: begin. symbol = {0}, bid = {1}, ask = {2}", symbol, bid, ask);
MtExpert expert;
lock (_experts)
@@ -111,14 +109,14 @@ namespace MTApiService
if (expert != null)
{
expert.Quote = new MtQuote { Instrument = symbol, Bid = bid, Ask = ask, ExpertHandle = expertHandle };
expert.UpdateQuote(new MtQuote { Instrument = symbol, Bid = bid, Ask = ask, ExpertHandle = expertHandle });
}
else
{
Log.WarnFormat("SendQuote: expert with id {0} has not been found.", expertHandle);
Log.WarnFormat("UpdateQuote: expert with id {0} has not been found.", expertHandle);
}
Log.Debug("SendQuote: end");
Log.Debug("UpdateQuote: end");
}
public void SendEvent(int expertHandle, int eventType, string payload)
@@ -272,6 +270,31 @@ namespace MTApiService
}
}
}
private void ExpertOnDeinited(object sender, EventArgs eventArgs)
{
Log.Debug("ExpertOnDeinited: begin.");
var expert = sender as MtExpert;
if (expert == null)
{
Log.Warn("expert_Deinited: end. Expert is not defined.");
return;
}
lock (_experts)
{
if (_experts.ContainsKey(expert.Handle))
{
_experts.Remove(expert.Handle);
}
}
Log.DebugFormat("ExpertOnDeinited: removed expert {0}", expert.Handle);
Log.Debug("ExpertOnDeinited: end.");
}
#endregion
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace MTApiService
Command = command;
}
public MtCommand Command { get; private set; }
public MtCommand Command { get; }
public MtResponse WaitResult(int time)
{
+17 -29
View File
@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace MTApiService
{
internal class MtExpert: ITaskExecutor
public class MtExpert: ITaskExecutor
{
public delegate void MtQuoteHandler(MtExpert expert, MtQuote quote);
public delegate void MtEventHandler(MtExpert expert, MtEvent e);
@@ -19,21 +19,20 @@ namespace MTApiService
#endregion
#region Public Methods
public MtExpert(int handle, MtQuote quote, IMetaTraderHandler mtHandler)
public MtExpert(int handle, string symbol, double bid, double ask, IMetaTraderHandler mtHandler)
{
if (mtHandler == null)
throw new ArgumentNullException(nameof(mtHandler));
Quote = quote;
_quote = new MtQuote { ExpertHandle = handle, Instrument = symbol, Bid = bid, Ask = ask};
Handle = handle;
_mtHadler = mtHandler;
}
public void Deinit()
public virtual void Deinit()
{
Log.Debug("Deinit: begin.");
IsEnable = false;
FireOnDeinited();
Log.Debug("Deinit: end.");
@@ -49,7 +48,7 @@ namespace MTApiService
Log.Debug("SendResponse: end.");
}
public int GetCommandType()
public virtual int GetCommandType()
{
Log.Debug("GetCommandType: called.");
@@ -111,7 +110,7 @@ namespace MTApiService
return command.NamedParams.ContainsKey(name);
}
public void SendEvent(MtEvent mtEvent)
public virtual void SendEvent(MtEvent mtEvent)
{
Log.DebugFormat("SendEvent: begin. event = {0}", mtEvent);
@@ -120,9 +119,18 @@ namespace MTApiService
Log.Debug("SendEvent: end.");
}
public void UpdateQuote(MtQuote quote)
{
Log.DebugFormat("UpdateQuote: begin. quote = {0}", quote);
Quote = quote;
Log.Debug("UpdateQuote: end.");
}
public override string ToString()
{
return $"ExpertHandle = {Handle}";
return $"ExpertHandle = {Handle}, Quote = {Quote}";
}
#endregion
@@ -153,7 +161,7 @@ namespace MTApiService
return _quote;
}
}
set
private set
{
lock (_locker)
{
@@ -165,26 +173,6 @@ namespace MTApiService
}
public int Handle { get; }
private bool _isEnable = true;
public bool IsEnable
{
get
{
lock (_locker)
{
return _isEnable;
}
}
private set
{
lock (_locker)
{
_isEnable = value;
}
}
}
#endregion
#region Private Methods
+7 -3
View File
@@ -9,9 +9,9 @@ namespace MTApiService
[DataMember]
public int Action { get; set; }
[DataMember]
public uint Magic { get; set; }
public ulong Magic { get; set; }
[DataMember]
public uint Order { get; set; }
public ulong Order { get; set; }
[DataMember]
public string Symbol { get; set; }
[DataMember]
@@ -25,7 +25,7 @@ namespace MTApiService
[DataMember]
public double Tp { get; set; }
[DataMember]
public uint Deviation { get; set; }
public ulong Deviation { get; set; }
[DataMember]
public int Type { get; set; }
[DataMember]
@@ -36,5 +36,9 @@ namespace MTApiService
public DateTime Expiration { get; set; }
[DataMember]
public string Comment { get; set; }
[DataMember]
public ulong Position { get; set; }
[DataMember]
public ulong PositionBy { get; set; }
}
}
-5
View File
@@ -80,11 +80,6 @@ namespace MTApiService
//init network hosts
var dnsHostName = Dns.GetHostName();
var ips = Dns.GetHostEntry(dnsHostName);
if (ips == null)
{
Log.WarnFormat("InitHosts: end. Dns.GetHostEntry has returned null for DNS Host Name {0}", dnsHostName);
return false;
}
foreach (var ipAddress in ips.AddressList)
{
+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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.27.0")]
[assembly: AssemblyFileVersion("1.0.27.0")]
[assembly: AssemblyVersion("1.0.30.0")]
[assembly: AssemblyFileVersion("1.0.30.0")]
+3 -4
View File
@@ -44,17 +44,16 @@ template <typename T> T Execute(std::function<T()> func, wchar_t* err, T default
_DLLAPI bool _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, wchar_t* err)
{
return Execute<bool>([&expertHandle, &port, symbol, &bid, &ask]() {
MT4Handler^ mtHandler = gcnew MT4Handler();
MtAdapter::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHandler);
auto expert = gcnew MtExpert(expertHandle, gcnew String(symbol), bid, ask, gcnew MT4Handler());
MtAdapter::GetInstance()->AddExpert(port, expert);
return true;
}, err, false);
}
_DLLAPI bool _stdcall deinitExpert(int expertHandle, wchar_t* err)
{
return Execute<bool>([&expertHandle]() {
MtAdapter::GetInstance()->DeinitExpert(expertHandle);
MtAdapter::GetInstance()->RemoveExpert(expertHandle);
return true;
}, err, false);
}
+24
View File
@@ -0,0 +1,24 @@
using System;
namespace MtApi
{
public class ChartEventArgs : EventArgs
{
internal ChartEventArgs(int expertHandle, MtChartEvent chartEvent)
{
ExpertHandle = expertHandle;
ChartId = chartEvent.ChartId;
EventId = chartEvent.EventId;
Lparam = chartEvent.Lparam;
Dparam = chartEvent.Dparam;
Sparam = chartEvent.Sparam;
}
public int ExpertHandle { get; }
public long ChartId { get; }
public int EventId { get; }
public long Lparam { get; }
public double Dparam { get; }
public string Sparam { get; }
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace MtApi
{
public enum EnumAlignMode
{
ALIGN_LEFT = 1,
ALIGN_CENTER = 2,
ALIGN_RIGHT = 0
}
}
+18
View File
@@ -0,0 +1,18 @@
namespace MtApi
{
public enum EnumChartEvent
{
CHARTEVENT_KEYDOWN = 0,
CHARTEVENT_MOUSE_MOVE = 10,
CHARTEVENT_OBJECT_CREATE = 7,
CHARTEVENT_OBJECT_CHANGE = 8,
CHARTEVENT_OBJECT_DELETE = 6,
CHARTEVENT_CLICK = 4,
CHARTEVENT_OBJECT_CLICK = 1,
CHARTEVENT_OBJECT_DRAG = 2,
CHARTEVENT_OBJECT_ENDEDIT = 3,
CHARTEVENT_CHART_CHANGE = 9,
CHARTEVENT_CUSTOM = 1000,
CHARTEVENT_CUSTOM_LAST = 66534
}
}
+13
View File
@@ -0,0 +1,13 @@
namespace MtApi
{
public enum EnumChartPropertyDouble
{
CHART_SHIFT_SIZE = 3,
CHART_FIXED_POSITION = 41,
CHART_FIXED_MAX = 8,
CHART_FIXED_MIN = 9,
CHART_POINTS_PER_BAR = 11,
CHART_PRICE_MIN = 108,
CHART_PRICE_MAX = 109
}
}
+55
View File
@@ -0,0 +1,55 @@
namespace MtApi
{
public enum EnumChartPropertyInteger
{
CHART_BRING_TO_TOP = 35,
CHART_MOUSE_SCROLL = 42,
CHART_EVENT_MOUSE_MOVE = 40,
CHART_EVENT_OBJECT_CREATE = 38,
CHART_EVENT_OBJECT_DELETE = 39,
CHART_MODE = 0,
CHART_FOREGROUND = 1,
CHART_SHIFT = 2,
CHART_AUTOSCROLL = 4,
CHART_QUICK_NAVIGATION = 45,
CHART_SCALE = 5,
CHART_SCALEFIX = 6,
CHART_SCALEFIX_11 = 7,
CHART_SCALE_PT_PER_BAR = 10,
CHART_SHOW_OHLC = 12,
CHART_SHOW_BID_LINE = 13,
CHART_SHOW_ASK_LINE = 14,
CHART_SHOW_LAST_LINE = 15,
CHART_SHOW_PERIOD_SEP = 16,
CHART_SHOW_GRID = 17,
CHART_SHOW_VOLUMES = 18,
CHART_SHOW_OBJECT_DESCR = 19,
CHART_VISIBLE_BARS = 100,
CHART_WINDOWS_TOTAL = 101,
CHART_WINDOW_IS_VISIBLE = 102,
CHART_WINDOW_HANDLE = 103,
CHART_WINDOW_YDISTANCE = 110,
CHART_FIRST_VISIBLE_BAR = 104,
CHART_WIDTH_IN_BARS = 105,
CHART_WIDTH_IN_PIXELS = 106,
CHART_HEIGHT_IN_PIXELS = 107,
CHART_COLOR_BACKGROUND = 21,
CHART_COLOR_FOREGROUND = 22,
CHART_COLOR_GRID = 23,
CHART_COLOR_VOLUME = 24,
CHART_COLOR_CHART_UP = 25,
CHART_COLOR_CHART_DOWN = 26,
CHART_COLOR_CHART_LINE = 27,
CHART_COLOR_CANDLE_BULL = 28,
CHART_COLOR_CANDLE_BEAR = 29,
CHART_COLOR_BID = 30,
CHART_COLOR_ASK = 31,
CHART_COLOR_LAST = 32,
CHART_COLOR_STOP_LEVEL = 33,
CHART_SHOW_TRADE_LEVELS = 34,
CHART_DRAG_TRADE_LEVELS = 43,
CHART_SHOW_DATE_SCALE = 36,
CHART_SHOW_PRICE_SCALE = 37,
CHART_IS_OFFLINE = 112
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace MtApi
{
public enum EnumChartPropertyString
{
CHART_COMMENT = 20
}
}
+6
View File
@@ -58,7 +58,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChartEventArgs.cs" />
<Compile Include="ChartPeriod.cs" />
<Compile Include="EnumAlignMode.cs" />
<Compile Include="EnumChartPropertyDouble.cs" />
<Compile Include="EnumChartPropertyInteger.cs" />
<Compile Include="EnumChartPropertyString.cs" />
<Compile Include="EnumColorFormat.cs" />
<Compile Include="EnumObject.cs" />
<Compile Include="EnumObjectPropertyDouble.cs" />
@@ -73,6 +78,7 @@
<Compile Include="Monitors\AvailabilityOrdersEventArgs.cs" />
<Compile Include="MqlRates.cs" />
<Compile Include="MqlTick.cs" />
<Compile Include="MtChartEvent.cs" />
<Compile Include="MtConnectionEventArgs.cs" />
<Compile Include="MtConnectionException.cs" />
<Compile Include="MtConnectionState.cs" />
+629 -10
View File
@@ -786,7 +786,7 @@ namespace MtApi
#endregion
#region Account Information
#region Account functions
public double AccountBalance()
{
@@ -869,6 +869,12 @@ namespace MtApi
return SendCommand<int>(MtCommandType.AccountStopoutMode, null);
}
public bool ChangeAccount(string login, string password, string host)
{
var commandParameters = new ArrayList { login, password, host};
return SendCommand<bool>(MtCommandType.ChangeAccount, commandParameters);
}
#endregion
#region Common Function
@@ -988,6 +994,12 @@ namespace MtApi
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
public DateTime TimeGMT()
{
var commandResponse = SendCommand<int>(MtCommandType.TimeGMT, null);
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
public int TimeDay(DateTime date)
{
var commandParameters = new ArrayList { MtApiTimeConverter.ConvertToMtTime(date) };
@@ -1727,9 +1739,9 @@ namespace MtApi
///</summary>
///<param name="symbolName">Symbol name.</param>
///<param name="propId">Identifier of a symbol property. The value can be one of the values of the ENUM_SYMBOL_INFO_DOUBLE enumeration.</param>
/// <returns>
///<returns>
/// The value of double type.
/// </returns>
///</returns>
public double SymbolInfoDouble(string symbolName, EnumSymbolInfoDouble propId)
{
var response = SendRequest<SymbolInfoDoubleResponse>(new SymbolInfoDoubleRequest
@@ -1745,9 +1757,9 @@ namespace MtApi
///Returns the corresponding property of a specified symbol.
///</summary>
///<param name="symbol">Symbol name.</param>
/// <returns>
///<returns>
/// MqlTick object, to which the current prices and time of the last price update will be placed.
/// </returns>
///</returns>
public MqlTick SymbolInfoTick(string symbol)
{
var response = SendRequest<SymbolInfoTickResponse>(new SymbolInfoTickRequest
@@ -1780,6 +1792,606 @@ namespace MtApi
var commandParameters = new ArrayList { chartId };
SendCommand<object>(MtCommandType.ChartRedraw, commandParameters);
}
///<summary>
///Applies a specific template from a specified file to the chart.
///</summary>
///<param name="chartId">Chart ID.</param>
///<param name="filename">The name of the file containing the template.</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartApplyTemplate(long chartId, string filename)
{
var commandParameters = new ArrayList { chartId, filename };
return SendCommand<bool>(MtCommandType.ChartApplyTemplate, commandParameters);
}
///<summary>
///Saves current chart settings in a template with a specified name.
///</summary>
///<param name="chartId">Chart ID.</param>
///<param name="filename">The filename to save the template. The ".tpl" extension will be added to the filename automatically; there is no need to specify it. The template is saved in data_folder\templates\ and can be used for manual application in the terminal. If a template with the same filename already exists, the contents of this file will be overwritten.</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartSaveTemplate(long chartId, string filename)
{
var commandParameters = new ArrayList { chartId, filename };
return SendCommand<bool>(MtCommandType.ChartSaveTemplate, commandParameters);
}
///<summary>
///The function returns the number of a subwindow where an indicator is drawn.
///</summary>
///<param name="chartId">Chart ID.</param>
///<param name="indicatorShortname">Short name of the indicator.</param>
///<returns>
///Subwindow number in case of success. In case of failure the function returns -1.
///</returns>
public int ChartWindowFind(long chartId, string indicatorShortname)
{
var commandParameters = new ArrayList { chartId, indicatorShortname };
return SendCommand<int>(MtCommandType.ChartWindowFind, commandParameters);
}
///<summary>
///The function returns the number of a subwindow where an indicator is drawn.
///</summary>
///<param name="chartId">Chart ID.</param>
///<param name="subWindow">The number of the chart subwindow. 0 means the main chart window.</param>
///<param name="time">The time value on the chart, for which the value in pixels along the X axis will be received.</param>
///<param name="price">The price value on the chart, for which the value in pixels along the Y axis will be received.</param>
///<param name="x">The variable, into which the conversion of time to X will be received. The origin is in the upper left corner of the main chart window.</param>
///<param name="y">The variable, into which the conversion of price to Y will be received. The origin is in the upper left corner of the main chart window.</param>
///<returns>
///Subwindow number in case of success. In case of failure the function returns -1.
///</returns>
public bool ChartTimePriceToXY(long chartId, int subWindow, DateTime? time, double price, out int x, out int y)
{
var commandParameters = new ArrayList { chartId, subWindow, MtApiTimeConverter.ConvertToMtTime(time), price };
var str = SendCommand<string>(MtCommandType.ChartTimePriceToXY, commandParameters);
var res = false;
x = 0;
y = 0;
if (!string.IsNullOrEmpty(str) && str.Contains(";"))
{
var values = str.Split(';');
if (values.Length > 1)
{
int.TryParse(values[0], out x);
int.TryParse(values[1], out y);
res = true;
}
}
return res;
}
///<summary>
///The function returns the number of a subwindow where an indicator is drawn.
///</summary>
///<param name="chartId">Chart ID.</param>
///<param name="x">The variable, into which the conversion of time to X will be received. The origin is in the upper left corner of the main chart window.</param>
///<param name="y">The variable, into which the conversion of price to Y will be received. The origin is in the upper left corner of the main chart window.</param>
///<param name="subWindow">The number of the chart subwindow. 0 means the main chart window.</param>
///<param name="time">The time value on the chart, for which the value in pixels along the X axis will be received.</param>
///<param name="price">The price value on the chart, for which the value in pixels along the Y axis will be received.</param>
///<returns>
///Subwindow number in case of success. In case of failure the function returns -1.
///</returns>
public bool ChartXYToTimePrice(long chartId, int x, int y, out int subWindow, out DateTime? time, out double price)
{
var commandParameters = new ArrayList { chartId, x, y };
var str = SendCommand<string>(MtCommandType.ChartXYToTimePrice, commandParameters);
var res = false;
subWindow = 0;
time = null;
price = double.NaN;
if (!string.IsNullOrEmpty(str) && str.Contains(";"))
{
var values = str.Split(';');
if (values.Length > 2)
{
int.TryParse(values[0], out subWindow);
int mt4Time;
int.TryParse(values[1], out mt4Time);
time = MtApiTimeConverter.ConvertFromMtTime(mt4Time);
double.TryParse(values[2], out price);
res = true;
}
}
return res;
}
///<summary>
///Opens a new chart with the specified symbol and period.
///</summary>
///<param name="symbol">Chart symbol. NULL means the symbol of the current chart (the Expert Advisor is attached to).</param>
///<param name="period"> Chart period (timeframe). Can be one of the ENUM_TIMEFRAMES values. 0 means the current chart period.</param>
///<returns>
///If successful, it returns the opened chart ID. Otherwise returns 0.
///</returns>
public long ChartOpen(string symbol, ENUM_TIMEFRAMES period)
{
var commandParameters = new ArrayList { symbol, (int)period };
return SendCommand<long>(MtCommandType.ChartOpen, commandParameters);
}
///<summary>
///Returns the ID of the first chart of the client terminal.
///</summary>
public long ChartFirst()
{
return SendCommand<long>(MtCommandType.ChartFirst, null);
}
///<summary>
///Returns the chart ID of the chart next to the specified one.
///</summary>
///<param name="chartId">Chart ID. 0 does not mean the current chart. 0 means "return the first chart ID".</param>
///<returns>
///Chart ID. If this is the end of the chart list, it returns -1.
///</returns>
public long ChartNext(long chartId)
{
var commandParameters = new ArrayList { chartId };
return SendCommand<long>(MtCommandType.ChartNext, commandParameters);
}
///<summary>
///Closes the specified chart.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<returns>
///If successful, returns true, otherwise false.
///</returns>
public bool ChartClose(long chartId)
{
var commandParameters = new ArrayList { chartId };
return SendCommand<bool>(MtCommandType.ChartClose, commandParameters);
}
///<summary>
///Returns the symbol name for the specified chart.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<returns>
///If chart does not exist, the result will be an empty string.
///</returns>
public string ChartSymbol(long chartId)
{
var commandParameters = new ArrayList { chartId };
return SendCommand<string>(MtCommandType.ChartSymbol, commandParameters);
}
///<summary>
///Returns the timeframe period of specified chart.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<returns>
///The function returns one of the ENUM_TIMEFRAMES values. If chart does not exist, it returns 0.
///</returns>
public ENUM_TIMEFRAMES ChartPeriod(long chartId)
{
var commandParameters = new ArrayList { chartId };
return (ENUM_TIMEFRAMES) SendCommand<int>(MtCommandType.ChartPeriod, commandParameters);
}
///<summary>
///Sets a value for a corresponding property of the specified chart. Chart property should be of a double type.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="propId">Chart property ID. Can be one of the ENUM_CHART_PROPERTY_DOUBLE values (except the read-only properties).</param>
///<param name="value">Property value.</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartSetDouble(long chartId, EnumChartPropertyDouble propId, double value)
{
var commandParameters = new ArrayList { chartId, (int)propId, value };
return SendCommand<bool>(MtCommandType.ChartSetDouble, commandParameters);
}
///<summary>
///Sets a value for a corresponding property of the specified chart. Chart property must be datetime, int, color, bool or char.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="propId">Chart property ID. It can be one of the ENUM_CHART_PROPERTY_INTEGER value (except the read-only properties).</param>
///<param name="value">Property value.</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartSetInteger(long chartId, EnumChartPropertyInteger propId, long value)
{
var commandParameters = new ArrayList { chartId, (int)propId, value };
return SendCommand<bool>(MtCommandType.ChartSetInteger, commandParameters);
}
///<summary>
///Sets a value for a corresponding property of the specified chart. Chart property must be of the string type.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="propId">Chart property ID. Its value can be one of the ENUM_CHART_PROPERTY_STRING values (except the read-only properties).</param>
///<param name="value">Property value string. String length cannot exceed 2045 characters (extra characters will be truncated).</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartSetString(long chartId, EnumChartPropertyString propId, string value)
{
var commandParameters = new ArrayList { chartId, (int)propId, value };
return SendCommand<bool>(MtCommandType.ChartSetString, commandParameters);
}
///<summary>
///Sets a value for a corresponding property of the specified chart. Chart property must be of the string type.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="propId">Chart property ID. This value can be one of the ENUM_CHART_PROPERTY_DOUBLE values.</param>
///<param name="subWindow">Number of the chart subwindow. For the first case, the default value is 0 (main chart window). The most of the properties do not require a subwindow number.</param>
///<returns>
///The value of double type.
///</returns>
public double ChartGetDouble(long chartId, EnumChartPropertyDouble propId, int subWindow = 0)
{
var commandParameters = new ArrayList { chartId, (int)propId, subWindow };
return SendCommand<double>(MtCommandType.ChartGetDouble, commandParameters);
}
///<summary>
///Returns the value of a corresponding property of the specified chart. Chart property must be of datetime, int or bool type.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="propId">Chart property ID. This value can be one of the ENUM_CHART_PROPERTY_INTEGER values.</param>
///<param name="subWindow">Number of the chart subwindow. For the first case, the default value is 0 (main chart window). The most of the properties do not require a subwindow number.</param>
///<returns>
///The value of long type.
///</returns>
public long ChartGetInteger(long chartId, EnumChartPropertyInteger propId, int subWindow = 0)
{
var commandParameters = new ArrayList { chartId, (int)propId, subWindow };
return SendCommand<long>(MtCommandType.ChartGetInteger, commandParameters);
}
///<summary>
///Returns the value of a corresponding property of the specified chart. Chart property must be of string type.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="propId">Chart property ID. This value can be one of the ENUM_CHART_PROPERTY_STRING values.</param>
///<returns>
///The value of string type.
///</returns>
public string ChartGetString(long chartId, EnumChartPropertyString propId)
{
var commandParameters = new ArrayList { chartId, (int)propId };
return SendCommand<string>(MtCommandType.ChartGetString, commandParameters);
}
///<summary>
///Performs shift of the specified chart by the specified number of bars relative to the specified position in the chart.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="position">Chart position to perform a shift. Can be one of the ENUM_CHART_POSITION values.</param>
///<param name="shift">Number of bars to shift the chart. Positive value means the right shift (to the end of chart), negative value means the left shift (to the beginning of chart). The zero shift can be used to navigate to the beginning or end of chart.</param>
///<returns>
///Returns true if successful, otherwise returns false.
///</returns>
public bool ChartNavigate(long chartId, int position, int shift = 0)
{
var commandParameters = new ArrayList { chartId, position, shift };
return SendCommand<bool>(MtCommandType.ChartNavigate, commandParameters);
}
///<summary>
///Performs shift of the specified chart by the specified number of bars relative to the specified position in the chart.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="subWindow">Number of the chart subwindow. 0 denotes the main chart subwindow.</param>
///<param name="indicatorShortname">The short name of the indicator which is set in the INDICATOR_SHORTNAME property with the IndicatorSetString() function. To get the short name of an indicator use the ChartIndicatorName() function.</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartIndicatorDelete(long chartId, int subWindow, string indicatorShortname)
{
var commandParameters = new ArrayList { chartId, subWindow, indicatorShortname };
return SendCommand<bool>(MtCommandType.ChartIndicatorDelete, commandParameters);
}
///<summary>
///Returns the short name of the indicator by the number in the indicators list on the specified chart window.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="subWindow">Number of the chart subwindow. 0 denotes the main chart subwindow.</param>
///<param name="index">the index of the indicator in the list of indicators. The numeration of indicators start with zero, i.e. the first indicator in the list has the 0 index. To obtain the number of indicators in the list use the ChartIndicatorsTotal() function.</param>
///<returns>
///The short name of the indicator which is set in the INDICATOR_SHORTNAME property with the IndicatorSetString() function.
///</returns>
public string ChartIndicatorName(long chartId, int subWindow, int index)
{
var commandParameters = new ArrayList { chartId, subWindow, index };
return SendCommand<string>(MtCommandType.ChartIndicatorName, commandParameters);
}
///<summary>
///Returns the number of all indicators applied to the specified chart window.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="subWindow">Number of the chart subwindow. 0 denotes the main chart subwindow.</param>
///<returns>
///The number of indicators in the specified chart window.
///</returns>
public int ChartIndicatorsTotal(long chartId, int subWindow)
{
var commandParameters = new ArrayList { chartId, subWindow };
return SendCommand<int>(MtCommandType.ChartIndicatorsTotal, commandParameters);
}
///<summary>
///Returns the number (index) of the chart subwindow the Expert Advisor or script has been dropped to. 0 means the main chart window.
///</summary>
public int ChartWindowOnDropped()
{
return SendCommand<int>(MtCommandType.ChartWindowOnDropped, null);
}
///<summary>
///Returns the price coordinate corresponding to the chart point the Expert Advisor or script has been dropped to.
///</summary>
public double ChartPriceOnDropped()
{
return SendCommand<double>(MtCommandType.ChartPriceOnDropped, null);
}
///<summary>
///Returns the time coordinate corresponding to the chart point the Expert Advisor or script has been dropped to.
///</summary>
public DateTime ChartTimeOnDropped()
{
var res = SendCommand<int>(MtCommandType.ChartTimeOnDropped, null);
return MtApiTimeConverter.ConvertFromMtTime(res);
}
///<summary>
///Returns the X coordinate of the chart point the Expert Advisor or script has been dropped to.
///</summary>
public int ChartXOnDropped()
{
return SendCommand<int>(MtCommandType.ChartXOnDropped, null);
}
///<summary>
///Returns the Y coordinateof the chart point the Expert Advisor or script has been dropped to.
///</summary>
public int ChartYOnDropped()
{
return SendCommand<int>(MtCommandType.ChartYOnDropped, null);
}
///<summary>
///Changes the symbol and period of the specified chart. The function is asynchronous, i.e. it sends the command and does not wait for its execution completion.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="symbol">Chart symbol. NULL value means the current chart symbol (Expert Advisor is attached to)</param>
///<param name="period">Chart period (timeframe). Can be one of the ENUM_TIMEFRAMES values. 0 means the current chart period.</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartSetSymbolPeriod(long chartId, string symbol, ENUM_TIMEFRAMES period)
{
var commandParameters = new ArrayList { chartId, symbol, (int)period };
return SendCommand<bool>(MtCommandType.ChartSetSymbolPeriod, commandParameters);
}
///<summary>
///Saves current chart screen shot as a GIF, PNG or BMP file depending on specified extension.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="filename">Screenshot file name. Cannot exceed 63 characters. Screenshot files are placed in the \Files directory.</param>
///<param name="width">Screenshot width in pixels.</param>
///<param name="height">Screenshot height in pixels.</param>
///<param name="alignMode">Output mode of a narrow screenshot.</param>
///<returns>
///Returns true if the command has been added to chart queue, otherwise false.
///</returns>
public bool ChartScreenShot(long chartId, string filename, int width, int height, EnumAlignMode alignMode = EnumAlignMode.ALIGN_RIGHT)
{
var commandParameters = new ArrayList { chartId, filename, width, height, (int)alignMode };
return SendCommand<bool>(MtCommandType.ChartScreenShot, commandParameters);
}
///<summary>
///Returns the amount of bars visible on the chart.
///</summary>
///<returns>
///The amount of bars visible on the chart.
///</returns>
public int WindowBarsPerChart()
{
return SendCommand<int>(MtCommandType.WindowBarsPerChart, null);
}
///<summary>
///Returns the name of the executed Expert Advisor, script, custom indicator, or library.
///</summary>
///<returns>
///The name of the executed Expert Advisor, script, custom indicator, or library, depending on the MQL4 program, from which this function has been called.
///</returns>
public string WindowExpertName()
{
return SendCommand<string>(MtCommandType.WindowExpertName, null);
}
///<summary>
///Returns the window index containing this specified indicator.
///</summary>
///<param name="name">Indicator short name.</param>
///<returns>
///If indicator with name was found, the function returns the window index containing this specified indicator, otherwise it returns -1.
///</returns>
public int WindowFind(string name)
{
var commandParameters = new ArrayList { name };
return SendCommand<int>(MtCommandType.WindowFind, commandParameters);
}
///<summary>
///Returns index of the first visible bar in the current chart window.
///</summary>
///<returns>
///Index of the first visible bar number in the current chart window.
///</returns>
public int WindowFirstVisibleBar()
{
return SendCommand<int>(MtCommandType.WindowFirstVisibleBar, null);
}
///<summary>
///Returns the system handle of the chart window.
///</summary>
///<param name="symbol">Symbol.</param>
///<param name="timeframe">Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.</param>
///<returns>
///Returns the system handle of the chart window. If the chart of symbol and timeframe has not been opened by the moment of function calling, 0 will be returned.
///</returns>
public int WindowHandle(string symbol, int timeframe)
{
var commandParameters = new ArrayList { symbol, timeframe };
return SendCommand<int>(MtCommandType.WindowHandle, commandParameters);
}
///<summary>
///Returns the visibility flag of the chart subwindow.
///</summary>
///<param name="index">Subwindow index.</param>
///<returns>
///Returns true if the chart subwindow is visible, otherwise returns false. The chart subwindow can be hidden due to the visibility properties of the indicator placed in it.
///</returns>
public bool WindowIsVisible(int index)
{
var commandParameters = new ArrayList { index };
return SendCommand<bool>(MtCommandType.WindowIsVisible, commandParameters);
}
///<summary>
///Returns the window index where Expert Advisor, custom indicator or script was dropped.
///</summary>
///<returns>
///The window index where Expert Advisor, custom indicator or script was dropped. This value is valid if the Expert Advisor, custom indicator or script was dropped by mouse.
///</returns>
public int WindowOnDropped()
{
return SendCommand<int>(MtCommandType.WindowOnDropped, null);
}
///<summary>
///Returns the maximal value of the vertical scale of the specified subwindow of the current chart.
///</summary>
///<param name="index">Chart subwindow index (0 - main chart window).</param>
///<returns>
///The maximal value of the vertical scale of the specified subwindow of the current chart.
///</returns>
public int WindowPriceMax(int index = 0)
{
var commandParameters = new ArrayList { index };
return SendCommand<int>(MtCommandType.WindowPriceMax, commandParameters);
}
///<summary>
///Returns the minimal value of the vertical scale of the specified subwindow of the current chart.
///</summary>
///<param name="index">Chart subwindow index (0 - main chart window).</param>
///<returns>
///The minimal value of the vertical scale of the specified subwindow of the current chart.
///</returns>
public int WindowPriceMin(int index = 0)
{
var commandParameters = new ArrayList { index };
return SendCommand<int>(MtCommandType.WindowPriceMin, commandParameters);
}
///<summary>
///Returns the price of the chart point where Expert Advisor or script was dropped.
///</summary>
///<returns>
///The price of the chart point where Expert Advisor or script was dropped. This value is only valid if the expert or script was dropped by mouse.
///</returns>
public double WindowPriceOnDropped()
{
return SendCommand<double>(MtCommandType.WindowPriceOnDropped, null);
}
///<summary>
///Redraws the current chart forcedly.
///</summary>
///<returns>
///Redraws the current chart forcedly. It is normally used after the objects properties have been changed.
///</returns>
public void WindowRedraw()
{
SendCommand<object>(MtCommandType.WindowRedraw, null);
}
///<summary>
///Saves current chart screen shot as a GIF file.
///</summary>
///<param name="filename">Screen shot file name. Screenshot is saved to \Files folder.</param>
///<param name="sizeX">Screen shot width in pixels.</param>
///<param name="sizeY">Screen shot height in pixels.</param>
///<param name="startBar">Index of the first visible bar in the screen shot. If 0 value is set, the current first visible bar will be shot. If no value or negative value has been set, the end-of-chart screen shot will be produced, indent being taken into consideration.</param>
///<param name="chartScale">Horizontal chart scale for screen shot. Can be in the range from 0 to 5. If no value or negative value has been set, the current chart scale will be used.</param>
///<param name="chartMode"> Chart displaying mode. It can take the following values: CHART_BAR (0 is a sequence of bars), CHART_CANDLE (1 is a sequence of candlesticks), CHART_LINE (2 is a close prices line). If no value or negative value has been set, the chart will be shown in its current mode.</param>
///<returns>
///Returns true if succeed, otherwise false.
///</returns>
public bool WindowScreenShot(string filename, int sizeX, int sizeY, int startBar = -1, int chartScale = -1, int chartMode = -1)
{
var commandParameters = new ArrayList { filename, sizeX, sizeY, startBar, chartScale, chartMode };
return SendCommand<bool>(MtCommandType.WindowScreenShot, commandParameters);
}
///<summary>
///Returns the time of the chart point where Expert Advisor or script was dropped.
///</summary>
///<returns>
///The time value of the chart point where expert or script was dropped. This value is only valid if the expert or script was dropped by mouse.
///</returns>
public DateTime WindowTimeOnDropped()
{
var res = SendCommand<int>(MtCommandType.WindowTimeOnDropped, null);
return MtApiTimeConverter.ConvertFromMtTime(res);
}
///<summary>
///Returns total number of indicator windows on the chart.
///</summary>
///<returns>
///Total number of indicator windows on the chart (including main chart).
///</returns>
public int WindowsTotal()
{
return SendCommand<int>(MtCommandType.WindowsTotal, null);
}
///<summary>
///Returns the value at X axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped.
///</summary>
///<returns>
///The value at X axis in pixels for the chart window client area point at which the expert or script was dropped. The value will be true only if the expert or script were moved with the mouse ("Drag'n'Drop") technique.
///</returns>
public int WindowXOnDropped()
{
return SendCommand<int>(MtCommandType.WindowXOnDropped, null);
}
///<summary>
///Returns the value at Y axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped.
///</summary>
///<returns>
///Returns the value at Y axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped. The value will be true only if the expert or script were moved with the mouse ("Drag'n'Drop") technique.
///</returns>
public int WindowYOnDropped()
{
return SendCommand<int>(MtCommandType.WindowYOnDropped, null);
}
#endregion
#region Object Functions
@@ -2462,18 +3074,24 @@ namespace MtApi
switch(eventType)
{
case MtEventTypes.LastTimeBar:
{
FireOnLastTimeBar(JsonConvert.DeserializeObject<MtTimeBar>(e.Payload));
}
FireOnLastTimeBar(e.ExpertHandle, JsonConvert.DeserializeObject<MtTimeBar>(e.Payload));
break;
case MtEventTypes.ChartEvent:
FireOnChartEvent(e.ExpertHandle, JsonConvert.DeserializeObject<MtChartEvent>(e.Payload));
break;
default:
throw new ArgumentOutOfRangeException();
}
}
private void FireOnLastTimeBar(MtTimeBar timeBar)
private void FireOnLastTimeBar(int expertHandler, MtTimeBar timeBar)
{
OnLastTimeBar?.Invoke(this, new TimeBarArgs(timeBar));
OnLastTimeBar?.Invoke(this, new TimeBarArgs(expertHandler, timeBar));
}
private void FireOnChartEvent(int expertHandler, MtChartEvent chartEvent)
{
OnChartEvent?.Invoke(this, new ChartEventArgs(expertHandler, chartEvent));
}
private void BacktestingReady()
@@ -2491,6 +3109,7 @@ namespace MtApi
public event EventHandler<MtQuoteEventArgs> QuoteRemoved;
public event EventHandler<MtConnectionEventArgs> ConnectionStateChanged;
public event EventHandler<TimeBarArgs> OnLastTimeBar;
public event EventHandler<ChartEventArgs> OnChartEvent;
#endregion
}
+11
View File
@@ -0,0 +1,11 @@
namespace MtApi
{
internal class MtChartEvent
{
public long ChartId { get; set; }
public int EventId { get; set; }
public long Lparam { get; set; }
public double Dparam { get; set; }
public string Sparam { get; set; }
}
}
Executable → Regular
+52 -3
View File
@@ -111,6 +111,7 @@
TimeSeconds = 86,
TimeYear = 87,
Year = 88,
TimeGMT = 281,
//Global Variables
GlobalVariableCheck = 89,
@@ -197,8 +198,6 @@
SymbolName = 201,
SymbolSelect = 202,
SymbolInfoInteger = 203,
ChartId = 206,
ChartRedraw = 207,
//Object Functions
ObjectCreate = 208,
@@ -229,6 +228,56 @@
ObjectSetText = 233,
ObjectType = 234,
UnlockTicks = 235
UnlockTicks = 235,
//Chart Operations
ChartId = 206,
ChartRedraw = 207,
ChartApplyTemplate = 236,
ChartSaveTemplate = 237,
ChartWindowFind = 238,
ChartTimePriceToXY = 239,
ChartXYToTimePrice = 240,
ChartOpen = 241,
ChartFirst = 242,
ChartNext = 243,
ChartClose = 244,
ChartSymbol = 245,
ChartPeriod = 246,
ChartSetDouble = 247,
ChartSetInteger = 248,
ChartSetString = 249,
ChartGetDouble = 250,
ChartGetInteger = 251,
ChartGetString = 252,
ChartNavigate = 253,
ChartIndicatorDelete = 254,
ChartIndicatorName = 255,
ChartIndicatorsTotal = 256,
ChartWindowOnDropped = 257,
ChartPriceOnDropped = 258,
ChartTimeOnDropped = 259,
ChartXOnDropped = 260,
ChartYOnDropped = 261,
ChartSetSymbolPeriod = 262,
ChartScreenShot = 263,
WindowBarsPerChart = 264,
WindowExpertName = 265,
WindowFind = 266,
WindowFirstVisibleBar = 267,
WindowHandle = 268,
WindowIsVisible = 269,
WindowOnDropped = 270,
WindowPriceMax = 271,
WindowPriceMin = 272,
WindowPriceOnDropped = 273,
WindowRedraw = 274,
WindowScreenShot = 275,
WindowTimeOnDropped = 276,
WindowsTotal = 277,
WindowXOnDropped = 278,
WindowYOnDropped = 279,
ChangeAccount = 280
}
}
+2 -1
View File
@@ -2,6 +2,7 @@
{
public enum MtEventTypes
{
LastTimeBar = 1
LastTimeBar = 1,
ChartEvent = 2
}
}
+2 -11
View File
@@ -11,16 +11,7 @@ namespace MtApi
public double Close { get; set; }
public double High { get; set; }
public double Low { get; set; }
public DateTime OpenTime
{
get { return MtApiTimeConverter.ConvertFromMtTime(MtOpenTime); }
}
public DateTime CloseTime
{
get { return MtApiTimeConverter.ConvertFromMtTime(MtCloseTime); }
}
public DateTime OpenTime => MtApiTimeConverter.ConvertFromMtTime(MtOpenTime);
public DateTime CloseTime => MtApiTimeConverter.ConvertFromMtTime(MtCloseTime);
}
}
+3 -1
View File
@@ -1,4 +1,6 @@
namespace MtApi
// ReSharper disable InconsistentNaming
namespace MtApi
{
public enum ENUM_TERMINAL_INFO_STRING
{
+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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.36.0")]
[assembly: AssemblyFileVersion("1.0.36.0")]
[assembly: AssemblyVersion("1.0.40.0")]
[assembly: AssemblyFileVersion("1.0.40.0")]
+8 -1
View File
@@ -4,11 +4,18 @@ namespace MtApi
{
public class TimeBarArgs: EventArgs
{
internal TimeBarArgs(int expertHandle, MtTimeBar timeBar)
: this(timeBar)
{
ExpertHandle = expertHandle;
}
public TimeBarArgs(MtTimeBar timeBar)
{
TimeBar = timeBar;
}
public MtTimeBar TimeBar { get; private set; }
public int ExpertHandle { get; }
public MtTimeBar TimeBar { get; }
}
}
+11
View File
@@ -0,0 +1,11 @@
namespace MtApi5.Events
{
internal enum Mt5EventTypes
{
OnTradeTransaction = 1,
OnBookEvent = 2,
OnTick = 3,
OnLastTimeBar = 4,
OnLockTicks = 5
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace MtApi5.Events
{
internal class OnBookEvent
{
public string Symbol { get; set; }
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace MtApi5.Events
{
public class OnLastTimeBarEvent
{
public MqlRates Rates { get; set; }
public string Instrument { get; set; }
public int ExpertHandle { get; set; }
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace MtApi5.Events
{
internal class OnLockTicksEvent
{
public string Instrument { get; set; }
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace MtApi5.Events
{
internal class OnTickEvent
{
public MqlTick Tick { get; set; }
public string Instrument { get; set; }
public int ExpertHandle { get; set; }
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace MtApi5.Events
{
internal class OnTradeTransactionEvent
{
public MqlTradeTransaction Trans { get; set; }
public MqlTradeRequest Request { get; set; }
public MqlTradeResult Result { get; set; }
}
}
+12 -8
View File
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// ReSharper disable InconsistentNaming
namespace MtApi5
{
public class MqlBookInfo
@@ -14,8 +10,16 @@ namespace MtApi5
this.volume = volume;
}
public ENUM_BOOK_TYPE type { get; private set; } // Order type from ENUM_BOOK_TYPE enumeration
public double price { get; private set; } // Price
public long volume { get; private set; } // Volume
public MqlBookInfo()
{ }
public ENUM_BOOK_TYPE type { get; set; } // Order type from ENUM_BOOK_TYPE enumeration
public double price { get; set; } // Price
public long volume { get; set; } // Volume
public override string ToString()
{
return $"type = {type}; price = {price}; volume = {volume}";
}
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace MtApi5
{
public class MqlParam
{
public ENUM_DATATYPE DataType { get; set; }
public long? IntegerValue { get; set; }
public double? DoubleValue { get; set; }
public string StringValue { get; set; }
}
}
+17 -3
View File
@@ -1,4 +1,5 @@
using System;
// ReSharper disable InconsistentNaming
using System;
namespace MtApi5
{
@@ -6,7 +7,19 @@ namespace MtApi5
{
public MqlRates(DateTime time, double open, double high, double low, double close, long tick_volume, int spread, long real_volume)
{
this.time = time;
mt_time = Mt5TimeConverter.ConvertToMtTime(time);
this.open = open;
this.high = high;
this.low = low;
this.close = close;
this.tick_volume = tick_volume;
this.spread = spread;
this.real_volume = real_volume;
}
internal MqlRates(long time, double open, double high, double low, double close, long tick_volume, int spread, long real_volume)
{
mt_time = time;
this.open = open;
this.high = high;
this.low = low;
@@ -20,7 +33,8 @@ namespace MtApi5
{
}
public DateTime time { get; set; } // Period start time
public DateTime time => Mt5TimeConverter.ConvertFromMtTime(mt_time); // Period start time
public long mt_time { get; set; } // Period start time (original MT time)
public double open { get; set; } // Open price
public double high { get; set; } // The highest price of the period
public double low { get; set; } // The lowest price of the period
+2 -1
View File
@@ -1,4 +1,5 @@
using System;
// ReSharper disable InconsistentNaming
using System;
namespace MtApi5
{
+17 -12
View File
@@ -1,20 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// ReSharper disable InconsistentNaming
namespace MtApi5
{
public class MqlTradeCheckResult
{
public uint Retcode { get; private set; } // Reply code
public double Balance { get; private set; } // Balance after the execution of the deal
public double Equity { get; private set; } // Equity after the execution of the deal
public double Profit { get; private set; } // Floating profit
public double Margin { get; private set; } // Margin requirements
public double Margin_free { get; private set; } // Free margin
public double Margin_level { get; private set; } // Margin level
public string Comment { get; private set; } // Comment to the reply code (description of the error)
public uint Retcode { get; set; } // Reply code
public double Balance { get; set; } // Balance after the execution of the deal
public double Equity { get; set; } // Equity after the execution of the deal
public double Profit { get; set; } // Floating profit
public double Margin { get; set; } // Margin requirements
public double Margin_free { get; set; } // Free margin
public double Margin_level { get; set; } // Margin level
public string Comment { get; set; } // Comment to the reply code (description of the error)
public MqlTradeCheckResult(uint retcode
, double balance
@@ -34,5 +31,13 @@ namespace MtApi5
Margin_level = margin_level;
Comment = comment;
}
public MqlTradeCheckResult()
{ }
public override string ToString()
{
return $"Retcode={Retcode}; Comment={Comment}; Balance={Balance}; Equity={Equity}; Profit={Profit}; Margin={Margin}; Margin_free={Margin_free}; Margin_level={Margin_level}";
}
}
}
+22 -4
View File
@@ -1,11 +1,13 @@
using System;
// ReSharper disable InconsistentNaming
using System;
using Newtonsoft.Json;
namespace MtApi5
{
public class MqlTradeRequest
{
public ENUM_TRADE_REQUEST_ACTIONS Action { get; set; } // Trade operation type
public uint Magic { get; set; } // Expert Advisor ID (magic number)
public ulong Magic { get; set; } // Expert Advisor ID (magic number)
public ulong Order { get; set; } // Order ticket
public string Symbol { get; set; } // Trade symbol
public double Volume { get; set; } // Requested volume for a deal in lots
@@ -13,11 +15,27 @@ namespace MtApi5
public double Stoplimit { get; set; } // StopLimit level of the order
public double Sl { get; set; } // Stop Loss level of the order
public double Tp { get; set; } // Take Profit level of the order
public uint Deviation { get; set; } // Maximal possible deviation from the requested price
public ulong Deviation { get; set; } // Maximal possible deviation from the requested price
public ENUM_ORDER_TYPE Type { get; set; } // Order type
public ENUM_ORDER_TYPE_FILLING Type_filling { get; set; } // Order execution type
public ENUM_ORDER_TYPE_TIME Type_time { get; set; } // Order expiration type
public DateTime Expiration { get; set; } // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
[JsonIgnore]
public DateTime Expiration // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
{
get { return Mt5TimeConverter.ConvertFromMtTime(MtExpiration); }
set { MtExpiration = Mt5TimeConverter.ConvertToMtTime(value); }
}
public string Comment { get; set; } // Order comment
public ulong Position { get; set; } // Position ticket
public ulong PositionBy { get; set; } // The ticket of an opposite position
public int MtExpiration { get; private set; }
public override string ToString()
{
return $"Action={Action}; Magic={Magic}; Order={Order}; Symbol={Symbol}; Volume={Volume}; Price={Price}; Stoplimit={Stoplimit}; Sl={Sl}; Tp={Tp}; Deviation={Deviation}; Type={Type}; Type_filling={Type_filling}; Type_time={Type_time}; Expiration={Expiration}; Comment={Comment}; Position={Position}; PositionBy={PositionBy}";
}
}
}
+28 -12
View File
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text;
// ReSharper disable InconsistentNaming
namespace MtApi5
{
@@ -19,14 +17,32 @@ namespace MtApi5
Request_id = request_id;
}
public uint Retcode { get; private set; } // Operation return code
public ulong Deal { get; private set; } // Deal ticket, if it is performed
public ulong Order { get; private set; } // Order ticket, if it is placed
public double Volume { get; private set; } // Deal volume, confirmed by broker
public double Price { get; private set; } // Deal price, confirmed by broker
public double Bid { get; private set; } // Current Bid price
public double Ask { get; private set; } // Current Ask price
public string Comment { get; private set; } // Broker comment to operation (by default it is filled by the operation description)
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch
internal MqlTradeResult(MqlTradeResult o)
{
Retcode = o.Retcode;
Deal = o.Deal;
Order = o.Order;
Volume = o.Volume;
Price = o.Price;
Bid = o.Bid;
Ask = o.Ask;
Comment = o.Comment;
Request_id = o.Request_id;
}
public uint Retcode { get; } // Operation return code
public ulong Deal { get; } // Deal ticket, if it is performed
public ulong Order { get; } // Order ticket, if it is placed
public double Volume { get; } // Deal volume, confirmed by broker
public double Price { get; } // Deal price, confirmed by broker
public double Bid { get; } // Current Bid price
public double Ask { get; } // Current Ask price
public string Comment { get; } // Broker comment to operation (by default it is filled by the operation description)
public uint Request_id { get; } // Request ID set by the terminal during the dispatch
public override string ToString()
{
return $"Retcode={Retcode}; Comment={Comment}; Deal={Deal}; Order={Order}; Volume={Volume}; Price={Price}; Bid={Bid}; Ask={Ask}; Request_id={Request_id}";
}
}
}
+39
View File
@@ -0,0 +1,39 @@
using System;
using Newtonsoft.Json;
namespace MtApi5
{
public class MqlTradeTransaction
{
public ulong Deal { get; set; } // Deal ticket
public ulong Order { get; set; } // Order ticket
public string Symbol { get; set; } // Trade symbol name
public ENUM_TRADE_TRANSACTION_TYPE Type { get; set; } // Trade transaction type
public ENUM_ORDER_TYPE OrderType { get; set; } // Order type
public ENUM_ORDER_STATE OrderState { get; set; } // Order state
public ENUM_DEAL_TYPE DealType { get; set; } // Deal type
public ENUM_ORDER_TYPE_TIME TimeType { get; set; } // Order type by action period
[JsonIgnore]
public DateTime TimeExpiration // Order expiration time
{
get { return Mt5TimeConverter.ConvertFromMtTime(MtTimeExpiration); }
set { MtTimeExpiration = Mt5TimeConverter.ConvertToMtTime(value); }
}
public double Price { get; set; } // Price
public double PriceTrigger { get; set; } // Stop limit order activation price
public double PriceSl { get; set; } // Stop Loss level
public double PriceTp { get; set; } // Take Profit level
public double Volume { get; set; } // Volume in lots
public ulong Position { get; set; } // Position ticket
public ulong PositionBy { get; set; } // Ticket of an opposite position
public int MtTimeExpiration { get; private set; }
public override string ToString()
{
return $"Deal={Deal}; Order={Order}; Symbol={Symbol}; Type={Type}; OrderType={OrderType}; OrderState={OrderState}; DealType={DealType}; TimeType={TimeType}; TimeExpiration={TimeExpiration}; Price={Price}; PriceTrigger{PriceTrigger}; PriceSl={PriceSl}; PriceTp={PriceTp}; Volume={Volume}; Position={Position}; PositionBy={PositionBy}";
}
}
}
+10
View File
@@ -0,0 +1,10 @@
using System;
namespace MtApi5
{
public class Mt5BookEventArgs : EventArgs
{
public int ExpertHandle { get; set; }
public string Symbol { get; set; } //Symbol of OnBookEvent event.
}
}
+148 -10
View File
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// ReSharper disable InconsistentNaming
namespace MtApi5
{
internal enum Mt5CommandType
@@ -10,10 +6,9 @@ namespace MtApi5
//NoCommand = 0
//trade operations
OrderSend = 1,
//OrderSend = 1,
OrderCalcMargin = 2,
OrderCalcProfit = 3,
OrderCheck = 4,
//OrderSendAsync = 5,
PositionsTotal = 6,
PositionGetSymbol = 7,
@@ -21,6 +16,7 @@ namespace MtApi5
PositionGetDouble = 9,
PositionGetInteger = 10,
PositionGetString = 11,
PositionGetTicket = 4,
OrdersTotal = 12,
OrderGetTicket = 13,
OrderSelect = 14,
@@ -99,20 +95,162 @@ namespace MtApi5
SymbolInfoSessionTrade = 59,
MarketBookAdd = 60,
MarketBookRelease = 61,
MarketBookGet = 62,
//MarketBookGet = 62,
OrderCloseAll = 63,
//CTrade
PositionClose = 64,
PositionOpen = 65,
//PositionOpenWithResult = 1065,
//Backtesting
BacktestingReady = 66,
IsTesting = 67,
Print = 68,
//Requests
MtRequest = 155,
PositionSelectByTicket = 69,
ObjectCreate = 70,
ObjectName = 71,
ObjectDelete = 72,
ObjectsDeleteAll = 73,
ObjectFind = 74,
ObjectGetTimeByValue = 75,
ObjectGetValueByTime = 76,
ObjectMove = 77,
ObjectsTotal = 78,
ObjectGetDouble = 79,
ObjectGetInteger = 80,
ObjectGetString = 81,
ObjectSetDouble = 82,
ObjectSetInteger = 83,
ObjectSetString = 84,
//TextSetFont = 85,
//TextOut = 86,
//TextGetSize = 87,
iAC = 88,
iAD = 89,
iADX = 90,
iADXWilder = 91,
iAlligator = 92,
iAMA = 93,
iAO = 94,
iATR = 95,
iBearsPower = 96,
iBands = 97,
iBullsPower = 98,
iCCI = 99,
iChaikin = 100,
//iCustom = 101,
iDEMA = 102,
iDeMarker = 103,
iEnvelopes = 104,
iForce = 105,
iFractals = 106,
iFrAMA = 107,
iGator = 108,
iIchimoku = 109,
iBWMFI = 110,
iMomentum = 111,
iMFI = 112,
iMA = 113,
iOsMA = 114,
iMACD = 115,
iOBV = 116,
iSAR = 117,
iRSI = 118,
iRVI = 119,
iStdDev = 120,
iStochastic = 121,
iTEMA = 122,
iTriX = 123,
iWPR = 124,
iVIDyA = 125,
iVolumes = 126,
//Date and Time
TimeCurrent = 127,
TimeTradeServer = 128,
TimeLocal = 129,
TimeGMT = 130,
IndicatorRelease = 131,
//Chart Operations
ChartId = 206,
ChartRedraw = 207,
ChartApplyTemplate = 236,
ChartSaveTemplate = 237,
ChartWindowFind = 238,
//ChartTimePriceToXY = 239,
//ChartXYToTimePrice = 240,
ChartOpen = 241,
ChartFirst = 242,
ChartNext = 243,
ChartClose = 244,
ChartSymbol = 245,
ChartPeriod = 246,
ChartSetDouble = 247,
ChartSetInteger = 248,
ChartSetString = 249,
ChartGetDouble = 250,
ChartGetInteger = 251,
ChartGetString = 252,
ChartNavigate = 253,
ChartIndicatorDelete = 254,
ChartIndicatorName = 255,
ChartIndicatorsTotal = 256,
ChartWindowOnDropped = 257,
ChartPriceOnDropped = 258,
ChartTimeOnDropped = 259,
ChartXOnDropped = 260,
ChartYOnDropped = 261,
ChartSetSymbolPeriod = 262,
ChartScreenShot = 263,
ChartIndicatorAdd = 280,
ChartIndicatorGet = 281,
// Terminal Operations
TerminalCompany = 68,
TerminalName = 69,
TerminalPath = 70,
//Checkup
GetLastError = 132,
TerminalInfoString = 153,
TerminalInfoInteger = 204,
TerminalInfoDouble = 205,
//Common Functions
Alert = 136,
Comment = 137, //TODO
GetTickCount = 138, //TODO
GetMicrosecondCount = 139, //TODO
MessageBox = 140, //TODO
PeriodSeconds = 141, //TODO
PlaySound = 142, //TODO
Print = 68,
ResetLastError = 143,
SendNotification = 144, //TODO
SendMail = 145, //TODO
//Global Variables
GlobalVariableCheck = 146,
GlobalVariableTime = 147,
GlobalVariableDel = 148,
GlobalVariableGet = 149,
GlobalVariableName = 150,
GlobalVariableSet = 151,
GlobalVariablesFlush = 152,
GlobalVariableTemp = 154,
GlobalVariableSetOnCondition = 156,
GlobalVariablesDeleteAll = 157,
GlobalVariablesTotal = 158,
UnlockTicks = 159,
PositionCloseAll = 160
}
}
+2 -2
View File
@@ -4,8 +4,8 @@ namespace MtApi5
{
public class Mt5ConnectionEventArgs: EventArgs
{
public Mt5ConnectionState Status { get; private set; }
public string ConnectionMessage { get; private set; }
public Mt5ConnectionState Status { get; }
public string ConnectionMessage { get; }
public Mt5ConnectionEventArgs(Mt5ConnectionState status, string message)
{
+819 -212
View File
File diff suppressed because it is too large Load Diff
+14
View File
@@ -0,0 +1,14 @@
using System;
namespace MtApi5
{
public class Mt5LockTicksEventArgs : EventArgs
{
internal Mt5LockTicksEventArgs(string symbol)
{
Symbol = symbol;
}
public string Symbol { get; }
}
}
+17 -7
View File
@@ -1,21 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MTApiService;
namespace MtApi5
{
public class Mt5Quote
{
public string Instrument { get; private set; }
public double Bid { get; private set; }
public double Ask { get; private set; }
public string Instrument { get; }
public double Bid { get; }
public double Ask { get; }
public int ExpertHandle { get; set; }
public DateTime Time { get; set; }
public double Last { get; set; }
public ulong Volume { get; set; }
// public long TimeMsc { get; set; }
// public uint Flags { get; set; }
public Mt5Quote(string instrument, double bid, double ask)
internal Mt5Quote(string instrument, double bid, double ask)
{
Instrument = instrument;
Bid = bid;
Ask = ask;
}
internal Mt5Quote(MtQuote quote)
:this(quote.Instrument, quote.Bid, quote.Ask)
{
ExpertHandle = quote.ExpertHandle;
}
}
}
+1 -4
View File
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MtApi5
{
public class Mt5QuoteEventArgs: EventArgs
{
public Mt5Quote Quote { get; private set; }
public Mt5Quote Quote { get; }
public Mt5QuoteEventArgs(Mt5Quote quote)
{
+18
View File
@@ -0,0 +1,18 @@
using System;
namespace MtApi5
{
public class Mt5TimeBarArgs: EventArgs
{
internal Mt5TimeBarArgs(int expertHandle, string symbol, MqlRates rates)
{
ExpertHandle = expertHandle;
Rates = rates;
Symbol = symbol;
}
public int ExpertHandle { get; }
public string Symbol { get; }
public MqlRates Rates { get; }
}
}
+9 -13
View File
@@ -1,32 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MtApi5
{
class Mt5TimeConverter
internal class Mt5TimeConverter
{
public static DateTime ConvertFromMtTime(int time)
{
DateTime tmpTime = new DateTime(1970, 1, 1);
var tmpTime = new DateTime(1970, 1, 1);
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
}
public static DateTime ConvertFromMtTime(long time)
{
DateTime tmpTime = new DateTime(1970, 1, 1);
var tmpTime = new DateTime(1970, 1, 1);
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
}
public static int ConvertToMtTime(DateTime time)
public static int ConvertToMtTime(DateTime? time)
{
int result = 0;
if (time != DateTime.MinValue)
{
DateTime tmpTime = new DateTime(1970, 1, 1);
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
}
var result = 0;
if (time == null || time == DateTime.MinValue)
return result;
var tmpTime = new DateTime(1970, 1, 1);
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
return result;
}
}
+12
View File
@@ -0,0 +1,12 @@
using System;
namespace MtApi5
{
public class Mt5TradeTransactionEventArgs : EventArgs
{
public int ExpertHandle { get; set; }
public MqlTradeTransaction Trans { get; set; } // trade transaction structure
public MqlTradeRequest Request { get; set; } // request structure
public MqlTradeResult Result { get; set; } // result structure
}
}
+30 -2
View File
@@ -48,10 +48,20 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CopyTicksFlag.cs" />
<Compile Include="Events\OnBookEvent.cs" />
<Compile Include="Events\OnLastTimeBarEvent.cs" />
<Compile Include="Events\OnLockTicksEvent.cs" />
<Compile Include="Events\OnTickEvent.cs" />
<Compile Include="Events\OnTradeTransactionEvent.cs" />
<Compile Include="Mt5LockTicksEventArgs.cs" />
<Compile Include="Mt5TimeBarArgs.cs" />
<Compile Include="MqlBookInfo.cs" />
<Compile Include="MqlParam.cs" />
<Compile Include="MqlRates.cs" />
<Compile Include="MqlTick.cs" />
<Compile Include="MqlTradeCheckResult.cs" />
<Compile Include="MqlTradeTransaction.cs" />
<Compile Include="Mt5BookEventArgs.cs" />
<Compile Include="Mt5TimeConverter.cs" />
<Compile Include="Mt5Enums.cs" />
<Compile Include="Mt5ConnectionEventArgs.cs" />
@@ -59,18 +69,35 @@
<Compile Include="MqlTradeRequest.cs" />
<Compile Include="MqlTradeResult.cs" />
<Compile Include="Mt5QuoteEventArgs.cs" />
<Compile Include="Mt5TradeTransactionEventArgs.cs" />
<Compile Include="MtApi5Client.cs" />
<Compile Include="Mt5CommandType.cs" />
<Compile Include="MtConverters.cs" />
<Compile Include="ErrorCode.cs" />
<Compile Include="ExecutionException.cs" />
<Compile Include="Events\Mt5EventTypes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Mt5Quote.cs" />
<Compile Include="Requests\ChartTimePriceToXyRequest.cs" />
<Compile Include="Requests\ChartTimePriceToXyResult.cs" />
<Compile Include="Requests\ChartXyToTimePriceRequest.cs" />
<Compile Include="Requests\ChartXyToTimePriceResult.cs" />
<Compile Include="Requests\CopyTicksRequest.cs" />
<Compile Include="Requests\ICustomRequest.cs" />
<Compile Include="Requests\IndicatorCreateRequest.cs" />
<Compile Include="Requests\MarketBookGetRequest.cs" />
<Compile Include="Requests\OrderCheckRequest.cs" />
<Compile Include="Requests\OrderCheckResult.cs" />
<Compile Include="Requests\OrderSendRequest.cs" />
<Compile Include="Requests\PositionCloseRequest.cs" />
<Compile Include="Requests\PositionCloseResult.cs" />
<Compile Include="Requests\PositionOpenRequest.cs" />
<Compile Include="Requests\RequestBase.cs" />
<Compile Include="Requests\RequestType.cs" />
<Compile Include="Responses\CopyTicksResponse.cs" />
<Compile Include="Responses\ResponseBase.cs" />
<Compile Include="Requests\OrderSendResult.cs" />
<Compile Include="Requests\Response.cs" />
<Compile Include="Requests\SymbolInfoStringRequest.cs" />
<Compile Include="Requests\SymbolInfoStringResult.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
@@ -81,6 +108,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
+1793 -55
View File
File diff suppressed because it is too large Load Diff
+19 -77
View File
@@ -6,84 +6,14 @@ namespace MtApi5
{
internal static class MtConverters
{
private static readonly MtLog Log = LogConfigurator.GetLogger(typeof(MtConverters));
#region Values Converters
public static Mt5Quote Parse(this MtQuote quote)
{
return (quote != null) ? new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask) : null;
}
public static bool ParseResult(this string inputString, char separator, out MqlTradeResult result)
{
var retVal = false;
result = null;
if (string.IsNullOrEmpty(inputString) == false)
{
var values = inputString.Split(separator);
if (values.Length == 10)
{
try
{
retVal = int.Parse(values[0]) != 0;
var retcode = uint.Parse(values[1]);
var deal = ulong.Parse(values[2]);
var order = ulong.Parse(values[3]);
var volume = double.Parse(values[4]);
var price = double.Parse(values[5]);
var bid = double.Parse(values[6]);
var ask = double.Parse(values[7]);
var comment = values[8];
var requestId = uint.Parse(values[9]);
result = new MqlTradeResult(retcode, deal, order, volume, price, bid, ask, comment, requestId);
}
catch (Exception)
{
}
}
}
return retVal;
}
public static bool ParseResult(this string inputString, char separator, out MqlTradeCheckResult result)
{
var retVal = false;
result = null;
if (string.IsNullOrEmpty(inputString) == false)
{
var values = inputString.Split(separator);
if (values.Length == 10)
{
try
{
retVal = int.Parse(values[0]) != 0;
var retcode = uint.Parse(values[1]);
var balance = double.Parse(values[2]);
var equity = double.Parse(values[3]);
var profit = double.Parse(values[4]);
var margin = double.Parse(values[5]);
var marginFree = double.Parse(values[6]);
var marginLevel = double.Parse(values[7]);
var comment = values[8];
result = new MqlTradeCheckResult(retcode, balance, equity, profit, margin, marginFree, marginLevel, comment);
}
catch (Exception)
{
retVal = false;
}
}
}
return retVal;
}
public static bool ParseResult(this string inputString, char separator, out double result)
{
Log.Debug($"ParseResult: inputString = {inputString}, separator = {separator}");
var retVal = false;
result = 0;
@@ -98,18 +28,25 @@ namespace MtApi5
result = double.Parse(values[1]);
}
catch (Exception)
catch (Exception ex)
{
retVal = false;
Log.Error($"ParseResult: {ex.Message}");
}
}
}
else
{
Log.Warn("ParseResult: input srting is null or empty!");
}
return retVal;
}
public static bool ParseResult(this string inputString, char separator, out DateTime from, out DateTime to)
{
Log.Debug($"ParseResult: inputString = {inputString}, separator = {separator}");
var retVal = false;
from = new DateTime();
@@ -130,12 +67,17 @@ namespace MtApi5
var iTo= int.Parse(values[2]);
to = Mt5TimeConverter.ConvertFromMtTime(iTo);
}
catch (Exception)
catch (Exception ex)
{
retVal = false;
Log.Error($"ParseResult: {ex.Message}");
}
}
}
else
{
Log.Warn("ParseResult: input srting is null or empty!");
}
return retVal;
}
@@ -149,7 +91,7 @@ namespace MtApi5
return new ArrayList { (int)request.Action, request.Magic, request.Order, request.Symbol, request.Volume
, request.Price, request.Stoplimit, request.Sl, request.Tp, request.Deviation, (int)request.Type
, (int)request.Type_filling, (int)request.Type_time, exp, request.Comment };
, (int)request.Type_filling, (int)request.Type_time, exp, request.Comment, request.Position, request.PositionBy };
}
#endregion
+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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.12")]
[assembly: AssemblyFileVersion("1.0.12")]
[assembly: AssemblyVersion("1.0.19")]
[assembly: AssemblyFileVersion("1.0.19")]
@@ -0,0 +1,16 @@
using System;
namespace MtApi5.Requests
{
internal class ChartTimePriceToXyRequest : RequestBase
{
public override RequestType RequestType => RequestType.ChartTimePriceToXY;
public long ChartId { get; set; }
public int SubWindow { get; set; }
public DateTime? Time { get; set; }
public double Price { get; set; }
public int MtTime => Mt5TimeConverter.ConvertToMtTime(Time);
}
}
@@ -0,0 +1,9 @@
namespace MtApi5.Requests
{
internal class ChartTimePriceToXyResult
{
public bool RetVal { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
}
@@ -0,0 +1,13 @@
using System;
namespace MtApi5.Requests
{
internal class ChartXyToTimePriceRequest : RequestBase
{
public override RequestType RequestType => RequestType.ChartXYToTimePrice;
public long ChartId { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
}
@@ -0,0 +1,14 @@
using System;
namespace MtApi5.Requests
{
internal class ChartXyToTimePriceResult
{
public bool RetVal { get; set; }
public int SubWindow { get; set; }
public DateTime? Time => Mt5TimeConverter.ConvertFromMtTime(MtTime);
public double Price { get; set; }
public int MtTime { get; set; }
}
}
+23
View File
@@ -0,0 +1,23 @@
using System.Collections;
namespace MtApi5.Requests
{
internal class ICustomRequest : RequestBase
{
public enum ParametersType
{
Int = 0,
Double = 1,
String = 2,
Boolean = 3
}
public string Symbol { get; set; }
public int Timeframe { get; set; }
public string Name { get; set; }
public ArrayList Params { get; set; }
public ParametersType ParamsType { get; set; }
public override RequestType RequestType => RequestType.iCustom;
}
}
+14
View File
@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace MtApi5.Requests
{
internal class IndicatorCreateRequest: RequestBase
{
public override RequestType RequestType => RequestType.IndicatorCreate;
public string Symbol { get; set; }
public ENUM_TIMEFRAMES Period { get; set; }
public ENUM_INDICATOR IndicatorType { get; set; }
public List<MqlParam> Parameters { get; set; }
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace MtApi5.Requests
{
internal class MarketBookGetRequest: RequestBase
{
public override RequestType RequestType => RequestType.MarketBookGet;
public string Symbol { get; set; }
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace MtApi5.Requests
{
internal class OrderCheckRequest: RequestBase
{
public override RequestType RequestType => RequestType.OrderCheck;
public MqlTradeRequest TradeRequest { get; set; }
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace MtApi5.Requests
{
public class OrderCheckResult
{
public bool RetVal { get; set; }
public MqlTradeCheckResult TradeCheckResult { get; set; }
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace MtApi5.Requests
{
internal class OrderSendRequest: RequestBase
{
public override RequestType RequestType => RequestType.OrderSend;
public MqlTradeRequest TradeRequest { get; set; }
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace MtApi5.Requests
{
internal class OrderSendResult
{
public bool RetVal { get; set; }
public MqlTradeResult TradeResult { get; set; }
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace MtApi5.Requests
{
internal class PositionCloseRequest : RequestBase
{
public override RequestType RequestType => RequestType.PositionClose;
public ulong Ticket { get; set; }
public ulong Deviation { get; set; }
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace MtApi5.Requests
{
internal class PositionCloseResult
{
public bool RetVal { get; set; }
public MqlTradeResult TradeResult { get; set; }
}
}
+15
View File
@@ -0,0 +1,15 @@
namespace MtApi5.Requests
{
internal class PositionOpenRequest: RequestBase
{
public override RequestType RequestType => RequestType.PositionOpen;
public string Symbol { get; set; }
public ENUM_ORDER_TYPE OrderType { get; set; }
public double Volume { get; set; }
public double Price { get; set; }
public double Sl { get; set; }
public double Tp { get; set; }
public string Comment { get; set; }
}
}
+15 -3
View File
@@ -1,8 +1,20 @@
namespace MtApi5.Requests
// ReSharper disable InconsistentNaming
namespace MtApi5.Requests
{
internal enum RequestType
{
Unknown = 0,
CopyTicks = 1
Unknown = 0,
CopyTicks = 1,
iCustom = 2,
OrderSend = 3,
PositionOpen = 4,
OrderCheck = 5,
MarketBookGet = 6,
IndicatorCreate = 7,
SymbolInfoString = 8,
ChartTimePriceToXY = 9,
ChartXYToTimePrice = 10,
PositionClose = 11
}
}
+4 -2
View File
@@ -1,8 +1,10 @@
namespace MtApi5.Responses
namespace MtApi5.Requests
{
internal class ResponseBase
internal class Response<T>
{
public int ErrorCode { get; set; }
public string ErrorMessage { get; set; }
public T Value { get; set; }
}
}
@@ -0,0 +1,10 @@
namespace MtApi5.Requests
{
internal class SymbolInfoStringRequest : RequestBase
{
public override RequestType RequestType => RequestType.SymbolInfoString;
public string SymbolName { get; set; }
public ENUM_SYMBOL_INFO_STRING PropId { get; set; }
}
}
@@ -0,0 +1,8 @@
namespace MtApi5.Requests
{
internal class SymbolInfoStringResult
{
public bool RetVal { get; set; }
public string StringVar { get; set; }
}
}
-9
View File
@@ -1,9 +0,0 @@
using System.Collections.Generic;
namespace MtApi5.Responses
{
internal class CopyTicksResponse: ResponseBase
{
public List<MqlTick> Ticks { get; set; }
}
}
+1
View File
@@ -10,6 +10,7 @@
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<RunWixToolsOutOfProc>true</RunWixToolsOutOfProc>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>..\build\installers\$(Configuration)\</OutputPath>
+14 -15
View File
@@ -1,24 +1,23 @@
# MtApi - .NET API for MetaTrader trading platform (MetaQuotes).
MtApi provides an .NET API interface to work with famous trading platfroms MetaTrader4 and MetaTrader5 (MetaQuotes).
The api is using directly connection to MetaTrader terminal and is working with MQL functions and the most functions of the api have MQL interface.
# MtApi - .NET API for MetaTrader Trading Platform (MetaQuotes).
MtApi provides a .NET API to work with famous trading platfroms MetaTrader4 and MetaTrader5 (MetaQuotes).
The API connects directly to the MetaTrader terminal and works with MQL functions. Most functions of the API have MQL interface.
The connection can be local or remote (by TCP).
# MtApi structure
# MtApi Structure
The project has two parts:
- client side (C#): MtApi and MtApi5;
- server side (C# and C++/CLI): MTApiService, MTConnector, MT5Connector, MQL experts.
Server side was designed with using WCF framework so it can be flaxible to setup connections but can be more slow compared with another connections types (for example, shared memory).
MTApiService is common engine communication project of the API for MT4 and MT5.
MTApiService library should be placed in Windows GAC (Global Assembly Cache). Installers in the project will copied it to GAC automatically.
Server side was designed using WCF framework with the intention of using flexibility to setup connections. One downside of using the WCF framework is the slower speed compared to other connection types (for example, shared memory).
MTApiService is a common engine communication project of the API for MT4 and MT5.
MTApiService library should be placed in Windows GAC (Global Assembly Cache). Installers in the project will be copied to GAC automatically.
# How to build solution
The project is supported by Visual Studio 2015.
It also requires WIX Tools (http://wixtoolset.org/).
# How to Build Solution
The project is supported by Visual Studio 2015 and requires WIX Tools (http://wixtoolset.org/).
To make api for MetaTrader4 use MtApiInstaller and for MetaTrader5 use MtApi5Installer.
All installers will be placed in folder "[root]\build\installers\" and all *.dll files will be placed in "[root]\build\products\".
MQL files have been build to ex4 and stored into folders "mq4" for MetaTrader and "mq5" for MetaTrader5. They are ready to using in terminals.
If you change source code of MQL expert you have to recompile it with MetaEditor. In this case you need to copy files "hash.mqh" and "json.mqh" to MetaEditor include folder.
To make an API for MetaTrader4 use MtApiInstaller and for MetaTrader5 use MtApi5Installer.
All installers will be placed in the folder "[root]\build\installers\" and all *.dll files will be placed in "[root]\build\products\".
MQL files have been build to ex4 and stored into folders "mq4" for MetaTrader and "mq5" for MetaTrader5. They are ready to be used in terminals.
Changing the source code of MQL expert requires recompilation with MetaEditor. Resulting in the need to copy files "hash.mqh" and "json.mqh" to the MetaEditor include folder.
# Home website
# Home Website
Please visit http://mtapi4.net
+520 -269
View File
@@ -4,7 +4,7 @@
xmlns:mtapi5="clr-namespace:MtApi5;assembly=MtApi5"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:mtApi5TestClient="clr-namespace:MtApi5TestClient"
Title="MainWindow" Height="700" Width="650"
Title="MainWindow" Height="700" Width="900"
Closing="Window_Closing">
<Window.Resources>
<DataTemplate x:Key="ConnectionTextBlockTemplate" DataType="{x:Type mtapi5:Mt5ConnectionState}">
@@ -78,19 +78,48 @@
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="ENUM_TERMINAL_INFO_INTEGER_Key" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="mtapi5:ENUM_TERMINAL_INFO_INTEGER"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="ENUM_TERMINAL_INFO_STRING_Key" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="mtapi5:ENUM_TERMINAL_INFO_STRING"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="ENUM_TERMINAL_INFO_DOUBLE_Key" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="mtapi5:ENUM_TERMINAL_INFO_DOUBLE"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="ENUM_TIMEFRAMES_Key" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="mtapi5:ENUM_TIMEFRAMES"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="ENUM_INDICATOR_Key" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="mtapi5:ENUM_INDICATOR"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
<Grid x:Name="_MainLayout">
<Grid.RowDefinitions>
<RowDefinition Height="0.65*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0.35*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
@@ -100,308 +129,530 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Expander ExpandDirection="Right" IsExpanded="True"
Grid.Row="0" Grid.Column="0" Margin="5">
<Expander.Header>
<TextBlock Text="Connection" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" Width="Auto">
<TextBlock.LayoutTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="-90"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</TextBlock.LayoutTransform>
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
</Expander.Header>
<Expander.Content>
<Grid Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Margin="2" Visibility="Visible" BorderThickness="1" BorderBrush="DarkBlue">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Host" Margin="5,2,2,2" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="2" Text="{Binding Host, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Port" Margin="5,2,2,2" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="2" Width="70" HorizontalAlignment="Left" Text="{Binding Port, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="30,5,0,10" >
<Button Content="Connect" Width="70" Command="{Binding ConnectCommand}" />
<Button Margin="10,0,0,0" Width="70" Content="Disconnect" Command="{Binding DisconnectCommand}" />
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Row="3" Margin="2" Visibility="Visible" BorderThickness="1" BorderBrush="DarkBlue">
<Grid Margin="3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Host"/>
<TextBox Grid.Row="0" Grid.Column="1"
Margin="5,0,0,0"
Text="{Binding Host, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Port"/>
<TextBox Grid.Row="1" Grid.Column="1"
Margin="5,0,0,0"
Text="{Binding Port, UpdateSourceTrigger=PropertyChanged}"/>
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Margin="5" Orientation="Horizontal">
<Button Content="Connect" Width="70" Command="{Binding ConnectCommand}" />
<Button Margin="5,0,0,0" Width="70" Content="Disconnect" Command="{Binding DisconnectCommand}" />
</StackPanel>
<Label Grid.Row="0" Content="Quotes" Background="LightYellow" />
<ListView Grid.Row="1" Margin="2"
ItemsSource="{Binding Quotes}"
SelectedItem="{Binding SelectedQuote}"
SelectionMode="Single">
<ListView.View>
<GridView>
<GridViewColumn Width="100" Header="Instrument" DisplayMemberBinding="{Binding Instrument}" />
<GridViewColumn Width="70" Header="Bid" DisplayMemberBinding="{Binding Bid}" />
<GridViewColumn Width="70" Header="Ask" DisplayMemberBinding="{Binding Ask}" />
<GridViewColumn Width="80" Header="ExpertHandle" DisplayMemberBinding="{Binding ExpertHandle}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Expander.Content>
</Expander>
</Border>
</Grid>
<ListView Grid.Row="0" Grid.Column="1"
ItemsSource="{Binding Quotes}"
SelectedItem="{Binding SelectedQuote}"
SelectionMode="Single">
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Instrument" DisplayMemberBinding="{Binding Instrument}" />
<GridViewColumn Width="80" Header="Bid" DisplayMemberBinding="{Binding Bid}" />
<GridViewColumn Width="80" Header="Ask" DisplayMemberBinding="{Binding Ask}" />
<GridViewColumn Width="80" Header="Feeds Count" DisplayMemberBinding="{Binding FeedCount}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
<TabControl Grid.Column="1" Margin="2">
<TabItem Header="Trade Functions">
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TabControl Grid.Row="1" >
<TabItem Header="Trade Functions">
<ScrollViewer>
<Expander Header="MqlTradeRequest" Margin="10" IsExpanded="True">
<Grid Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Action"/>
<ComboBox Grid.Column="1" Grid.Row="0" ItemsSource="{Binding Source={StaticResource ENUM_TRADE_REQUEST_ACTIONS_Key}}"
SelectedItem="{Binding TradeRequest.Action}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="0" Text="Magic" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="0" Text="{Binding TradeRequest.Magic}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Order"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding TradeRequest.Order}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="1" Text="Symbol" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="1" Text="{Binding TradeRequest.Symbol}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Volume"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding TradeRequest.Volume}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="2" Text="Price" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="2" Text="{Binding TradeRequest.Price}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Stoplimit"/>
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding TradeRequest.Stoplimit}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="3" Text="Sl" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="3" Text="{Binding TradeRequest.Sl}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="4" Text="Tp"/>
<TextBox Grid.Column="1" Grid.Row="4" Text="{Binding TradeRequest.Tp}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="4" Text="Deviation" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="4" Text="{Binding TradeRequest.Deviation}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="5" Text="Type"/>
<ComboBox Grid.Column="1" Grid.Row="5" ItemsSource="{Binding Source={StaticResource ENUM_ORDER_TYPE_Key}}"
SelectedItem="{Binding TradeRequest.Type}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="5" Text="Type_filling" Margin="10,0,0,0"/>
<ComboBox Grid.Column="3" Grid.Row="5" ItemsSource="{Binding Source={StaticResource ENUM_ORDER_TYPE_FILLING_Key}}"
SelectedItem="{Binding TradeRequest.Type_filling}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="6" Text="Type_time"/>
<ComboBox Grid.Column="1" Grid.Row="6" ItemsSource="{Binding Source={StaticResource ENUM_ORDER_TYPE_TIME_Key}}"
SelectedItem="{Binding TradeRequest.Type_time}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="6" Text="Expiration" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="6" Text="{Binding TradeRequest.Expiration}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="7" Text="Comment"/>
<TextBox Grid.Column="1" Grid.Row="7" Grid.ColumnSpan="3" Text="{Binding TradeRequest.Comment}" Margin="5,0,0,0"/>
</Grid>
</Expander>
<StackPanel Grid.Row="1" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button Content="OrderSend" Command="{Binding OrderSendCommand}" Width="100" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="OrderCheck" Command="{Binding OrderCheckCommand}" Width="100" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="PositionGetTicket" Command="{Binding PositionGetTicketCommand}" Width="100" Height="25" HorizontalAlignment="Left" Margin="4"/>
</StackPanel>
<WrapPanel>
<Button Content="HistoryDealGetDouble" Command="{Binding HistoryDealGetDoubleCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealGetInteger" Command="{Binding HistoryDealGetIntegerCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealGetString" Command="{Binding HistoryDealGetStringCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryOrderGetInteger" Command="{Binding HistoryOrderGetIntegerCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealMethods" Command="{Binding HistoryDealMethodsCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
</WrapPanel>
</StackPanel>
</Grid>
</ScrollViewer>
</TabItem>
<TabItem Header="Account Information">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.4*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Expander Header="MqlTradeRequest" Margin="10">
<Grid Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" Grid.Row="0"
SelectedItem="{Binding AccountInfoDoublePropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_ACCOUNT_INFO_DOUBLE_Key}}"/>
<Button Grid.Column="1" Grid.Row="0" Margin="10,0,0,0"
Command="{Binding AccountInfoDoubleCommand}"
Content="AccountInfoDouble" HorizontalAlignment="Left" />
<ComboBox Grid.Column="0" Grid.Row="1"
SelectedItem="{Binding AccountInfoIntegerPropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_ACCOUNT_INFO_INTEGER_Key}}"/>
<Button Grid.Column="1" Grid.Row="1" Margin="10,0,0,0"
Command="{Binding AccountInfoIntegerCommand}"
Content="AccountInfoInteger" HorizontalAlignment="Left" />
<ComboBox Grid.Column="0" Grid.Row="2"
SelectedItem="{Binding AccountInfoStringPropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_ACCOUNT_INFO_STRING_Key}}"/>
<Button Grid.Column="1" Grid.Row="2" Margin="10,0,0,0"
Command="{Binding AccountInfoStringCommand}"
Content="AccountInfoString" HorizontalAlignment="Left" />
</Grid>
</Grid>
</TabItem>
<TabItem Header="Terminal Information">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.4*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ComboBox Grid.Column="0" Grid.Row="0"
SelectedItem="{Binding TerminalInfoDoublePropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_TERMINAL_INFO_DOUBLE_Key}}"/>
<Button Grid.Column="1" Grid.Row="0" Margin="10,0,0,0"
Command="{Binding TerminalInfoDoubleCommand}"
Content="TerminalInfoDouble" HorizontalAlignment="Left" />
<ComboBox Grid.Column="0" Grid.Row="1"
SelectedItem="{Binding TerminalInfoIntegerPropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_TERMINAL_INFO_INTEGER_Key}}"/>
<Button Grid.Column="1" Grid.Row="1" Margin="10,0,0,0"
Command="{Binding TerminalInfoIntegerCommand}"
Content="TerminalInfoInteger" HorizontalAlignment="Left" />
<ComboBox Grid.Column="0" Grid.Row="2"
SelectedItem="{Binding TerminalInfoStringPropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_TERMINAL_INFO_STRING_Key}}"/>
<Button Grid.Column="1" Grid.Row="2" Margin="10,0,0,0"
Command="{Binding TerminalInfoStringCommand}"
Content="TerminalInfoString" HorizontalAlignment="Left" />
</Grid>
</Grid>
</TabItem>
<TabItem Header="Timeseries and Indicators Access">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" Margin="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Symbol Name" Margin="1"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="TimeFrame" Margin="1" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="StartPos" Margin="1" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="Count" Margin="1" HorizontalAlignment="Right"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}" Margin="1"/>
<ComboBox Grid.Row="1" Grid.Column="1" Margin="1"
ItemsSource="{Binding Source={StaticResource ENUM_TIMEFRAMES_Key}}"
SelectedItem="{Binding TimeSeriesValues.TimeFrame}"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding TimeSeriesValues.StartPos}" Margin="1"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding TimeSeriesValues.Count}" Margin="1"/>
</Grid>
<WrapPanel Grid.Row="1" Grid.Column="0" Margin="5">
<Button Command="{Binding CopyRatesCommand}" Margin="1"
Content="CopyRates" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTimesCommand}" Margin="1"
Content="CopyTimes" HorizontalAlignment="Left" />
<Button Command="{Binding CopyOpenCommand}" Margin="1"
Content="CopyOpen" HorizontalAlignment="Left" />
<Button Command="{Binding CopyHighCommand}" Margin="1"
Content="CopyHigh" HorizontalAlignment="Left" />
<Button Command="{Binding CopyLowCommand}" Margin="1"
Content="CopyLow" HorizontalAlignment="Left" />
<Button Command="{Binding CopyCloseCommand}" Margin="1"
Content="CopyClose" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTickVolumeCommand}" Margin="1"
Content="CopyTickVolume" HorizontalAlignment="Left" />
<Button Command="{Binding CopyRealVolumeCommand}" Margin="1"
Content="CopyRealVolume" HorizontalAlignment="Left" />
<Button Command="{Binding CopySpreadCommand}" Margin="1"
Content="CopySpread" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTicksCommand}" Margin="1"
Content="CopyTicks" HorizontalAlignment="Left" />
</WrapPanel>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Action"/>
<ComboBox Grid.Column="1" Grid.Row="0" ItemsSource="{Binding Source={StaticResource ENUM_TRADE_REQUEST_ACTIONS_Key}}"
SelectedItem="{Binding TradeRequest.Action}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="0" Text="Magic" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="0" Text="{Binding TradeRequest.Magic}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Order"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding TradeRequest.Order}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="1" Text="Symbol" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="1" Text="{Binding TradeRequest.Symbol}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Volume"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding TradeRequest.Volume}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="2" Text="Price" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="2" Text="{Binding TradeRequest.Price}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Stoplimit"/>
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding TradeRequest.Stoplimit}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="3" Text="Sl" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="3" Text="{Binding TradeRequest.Sl}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="4" Text="Tp"/>
<TextBox Grid.Column="1" Grid.Row="4" Text="{Binding TradeRequest.Tp}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="4" Text="Deviation" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="4" Text="{Binding TradeRequest.Deviation}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="5" Text="Type"/>
<ComboBox Grid.Column="1" Grid.Row="5" ItemsSource="{Binding Source={StaticResource ENUM_ORDER_TYPE_Key}}"
SelectedItem="{Binding TradeRequest.Type}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="5" Text="Type_filling" Margin="10,0,0,0"/>
<ComboBox Grid.Column="3" Grid.Row="5" ItemsSource="{Binding Source={StaticResource ENUM_ORDER_TYPE_FILLING_Key}}"
SelectedItem="{Binding TradeRequest.Type_filling}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="6" Text="Type_time"/>
<ComboBox Grid.Column="1" Grid.Row="6" ItemsSource="{Binding Source={StaticResource ENUM_ORDER_TYPE_TIME_Key}}"
SelectedItem="{Binding TradeRequest.Type_time}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="2" Grid.Row="6" Text="Expiration" Margin="10,0,0,0"/>
<TextBox Grid.Column="3" Grid.Row="6" Text="{Binding TradeRequest}" Margin="5,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="7" Text="Comment"/>
<TextBox Grid.Column="1" Grid.Row="7" Grid.ColumnSpan="3" Text="{Binding TradeRequest}" Margin="5,0,0,0"/>
<DockPanel Grid.Row="0" LastChildFill="True">
<Button DockPanel.Dock="Right" Command="{Binding IndicatorCreateCommand}" Margin="2"
Content="IndicatorCreate" HorizontalAlignment="Left" />
<ComboBox Margin="2"
ItemsSource="{Binding Source={StaticResource ENUM_INDICATOR_Key}}"
SelectedItem="{Binding TimeSeriesValues.IndicatorType}"/>
</DockPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Label Content="Indicator handle:" Margin="2"/>
<TextBox Margin="2" Width="60" PreviewTextInput="NumberValidationTextBox" Text="{Binding TimeSeriesValues.IndicatorHandle}"/>
<Button Command="{Binding IndicatorReleaseCommand}" Margin="2"
Content="IndicatorRelease" HorizontalAlignment="Left" />
</StackPanel>
</Grid>
</Expander>
</Grid>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Button Content="OrderSend" Command="{Binding OrderSendCommand}" Width="100" Height="25"/>
<ListBox Grid.Column="0" ItemsSource="{Binding TimeSeriesResults}" />
</Grid>
</TabItem>
<TabItem Header="Market Info">
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding SymbolsTotalCommand}" Content="SymbolsTotal" Margin="2"/>
<Button Command="{Binding SymbolNameCommand}" Content="SymbolName" Margin="2"/>
<Button Command="{Binding SymbolSelectCommand}" Content="SymbolSelect" Margin="2"/>
<Button Command="{Binding SymbolIsSynchronizedCommand}" Content="SymbolIsSynchronized" Margin="2"/>
<Button Command="{Binding SymbolInfoDoubleCommand}" Content="SymbolInfoDouble" Margin="2"/>
<Button Command="{Binding SymbolInfoIntegerCommand}" Content="SymbolInfoInteger" Margin="2"/>
<Button Command="{Binding SymbolInfoStringCommand}" Content="SymbolInfoString" Margin="2"/>
<Button Command="{Binding SymbolInfoString2Command}" Content="SymbolInfoString-2" Margin="2"/>
<Button Command="{Binding SymbolInfoTickCommand}" Content="SymbolInfoTick" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionQuoteCommand}" Content="SymbolInfoSessionQuote" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionTradeCommand}" Content="SymbolInfoSessionTrade" Margin="2"/>
<Button Command="{Binding MarketBookAddCommand}" Content="MarketBookAdd" Margin="2"/>
<Button Command="{Binding MarketBookReleaseCommand}" Content="MarketBookRelease" Margin="2"/>
<Button Command="{Binding MarketBookGetCommand}" Content="MarketBookGet" Margin="2"/>
</WrapPanel>
</TabItem>
<TabItem Header="CTrade (Positions)">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Command="{Binding PositionOpenCommand}" Content="PositionOpen" Margin="2" HorizontalAlignment="Left"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="4">
<TextBlock Text="Ticket:" VerticalAlignment="Center"/>
<TextBox Text="{Binding PositionTicketValue}" Width="150" Margin="2"/>
<Button Command="{Binding PositionCloseCommand}" Content="PositionClose" Margin="2"/>
</StackPanel>
<Button Grid.Row="2" Command="{Binding PositionCloseAllCommand}" Content="PositionCloseAll" Margin="2" HorizontalAlignment="Left"/>
</Grid>
</TabItem>
<TabItem Header="Indicators">
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding iCustomCommand}" Content="iCustom" Margin="2"/>
</WrapPanel>
</TabItem>
<TabItem Header="Chart Functions">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5">
<TextBlock Text="Symbol" VerticalAlignment="Center" Margin="2"/>
<TextBox Width="100" Text="{Binding ChartFunctionsSymbolValue}" Margin="2"/>
</StackPanel>
</Grid>
</ScrollViewer>
</TabItem>
<TabItem Header="Account Information">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.4*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="1" Orientation="Horizontal" Margin="5">
<Button Command="{Binding ChartOpenCommand}" Content="ChartOpen" Margin="2"/>
<Button Command="{Binding ChartTimePriceToXYCommand}" Content="ChartTimePriceToXY" Margin="2"/>
<Button Command="{Binding ChartXYToTimePriceCommand}" Content="ChartXYToTimePrice" Margin="2"/>
</WrapPanel>
<ComboBox Grid.Column="0" Grid.Row="0"
SelectedItem="{Binding AccountInfoDoublePropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_ACCOUNT_INFO_DOUBLE_Key}}"/>
<Button Grid.Column="1" Grid.Row="0" Margin="10,0,0,0"
Command="{Binding AccountInfoDoubleCommand}"
Content="AccountInfoDouble" HorizontalAlignment="Left" />
<WrapPanel Grid.Row="3" VerticalAlignment="Top" Margin="5">
<Button Command="{Binding ChartApplyTemplateCommand}" Content="ChartApplyTemplate" Margin="2"/>
<Button Command="{Binding ChartSaveTemplateCommand}" Content="ChartSaveTemplate" Margin="2"/>
</WrapPanel>
<ComboBox Grid.Column="0" Grid.Row="1"
SelectedItem="{Binding AccountInfoIntegerPropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_ACCOUNT_INFO_INTEGER_Key}}"/>
<Button Grid.Column="1" Grid.Row="1" Margin="10,0,0,0"
Command="{Binding AccountInfoIntegerCommand}"
Content="AccountInfoInteger" HorizontalAlignment="Left" />
<ComboBox Grid.Column="0" Grid.Row="2"
SelectedItem="{Binding AccountInfoStringPropertyId}"
ItemsSource="{Binding Source={StaticResource ENUM_ACCOUNT_INFO_STRING_Key}}"/>
<Button Grid.Column="1" Grid.Row="2" Margin="10,0,0,0"
Command="{Binding AccountInfoStringCommand}"
Content="AccountInfoString" HorizontalAlignment="Left" />
</Grid>
<Grid Margin="10" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Text="{Binding MessageText}" Margin="5"/>
<Button Grid.Column="1" Content="Print" Command="{Binding PrintCommand}" Margin="5"/>
</Grid>
</Grid>
</TabItem>
<TabItem Header="Timeseries and Indicators Access">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Text="symbolName"/>
<TextBox Grid.Row="1" Grid.Column="0" Text="timeframe"/>
<TextBox Grid.Row="2" Grid.Column="0" Text="startPos"/>
<TextBox Grid.Row="3" Grid.Column="0" Text="count"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}"/>
<ComboBox Grid.Row="1" Grid.Column="1"
ItemsSource="{Binding Source={StaticResource ENUM_TIMEFRAMES_Key}}"
SelectedItem="{Binding TimeSeriesValues.TimeFrame}"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding TimeSeriesValues.StartPos}"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding TimeSeriesValues.Count}"/>
<WrapPanel Grid.Row="4" Grid.ColumnSpan="2" Grid.Column="0" Margin="10">
<Button Command="{Binding CopyRatesCommand}" Margin="1"
Content="CopyRates" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTimesCommand}" Margin="1"
Content="CopyTimes" HorizontalAlignment="Left" />
<Button Command="{Binding CopyOpenCommand}" Margin="1"
Content="CopyOpen" HorizontalAlignment="Left" />
<Button Command="{Binding CopyHighCommand}" Margin="1"
Content="CopyHigh" HorizontalAlignment="Left" />
<Button Command="{Binding CopyLowCommand}" Margin="1"
Content="CopyLow" HorizontalAlignment="Left" />
<Button Command="{Binding CopyCloseCommand}" Margin="1"
Content="CopyClose" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTickVolumeCommand}" Margin="1"
Content="CopyTickVolume" HorizontalAlignment="Left" />
<Button Command="{Binding CopyRealVolumeCommand}" Margin="1"
Content="CopyRealVolume" HorizontalAlignment="Left" />
<Button Command="{Binding CopySpreadCommand}" Margin="1"
Content="CopySpread" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTicksCommand}" Margin="1"
Content="CopyTicks" HorizontalAlignment="Left" />
<StackPanel Grid.Row="4" Orientation="Horizontal" Margin="5">
<Button Command="{Binding ChartIdCommand}" Content="ChartId" Margin="2"/>
<TextBlock Text="ChartID" VerticalAlignment="Center" Margin="20,2,2,2"/>
<TextBox Width="150" Text="{Binding ChartFunctionsChartIdValue}" Margin="2"/>
</StackPanel>
<WrapPanel Grid.Row="5" VerticalAlignment="Top" Margin="5">
<Button Command="{Binding ChartRedrawCommand}" Content="ChartRedraw" Margin="2"/>
<Button Command="{Binding ChartWindowFindCommand}" Content="ChartWindowFind" Margin="2"/>
<Button Command="{Binding ChartCloseCommand}" Content="ChartClose" Margin="2"/>
<Button Command="{Binding ChartPeriodCommand}" Content="ChartPeriod" Margin="2"/>
<Button Command="{Binding ChartSetDoubleCommand}" Content="ChartSetDouble" Margin="2"/>
<Button Command="{Binding ChartSetIntegerCommand}" Content="ChartSetInteger" Margin="2"/>
<Button Command="{Binding ChartSetStringCommand}" Content="ChartSetString" Margin="2"/>
<Button Command="{Binding ChartGetDoubleCommand}" Content="ChartGetDouble" Margin="2"/>
<Button Command="{Binding ChartGetIntegerCommand}" Content="ChartGetInteger" Margin="2"/>
<Button Command="{Binding ChartNavigateCommand}" Content="ChartNavigate" Margin="2"/>
<Button Command="{Binding ChartIndicatorAddCommand}" Content="ChartIndicatorAdd" Margin="2"/>
<Button Command="{Binding ChartIndicatorDeleteCommand}" Content="ChartIndicatorDelete" Margin="2"/>
<Button Command="{Binding ChartIndicatorGetCommand}" Content="ChartIndicatorGet" Margin="2"/>
<Button Command="{Binding ChartIndicatorNameCommand}" Content="ChartIndicatorName" Margin="2"/>
<Button Command="{Binding ChartIndicatorsTotalCommand}" Content="ChartIndicatorsTotal" Margin="2"/>
<Button Command="{Binding ChartWindowOnDroppedCommand}" Content="ChartWindowOnDropped" Margin="2"/>
<Button Command="{Binding ChartPriceOnDroppedCommand}" Content="ChartPriceOnDropped" Margin="2"/>
<Button Command="{Binding ChartTimeOnDroppedCommand}" Content="ChartTimeOnDropped" Margin="2"/>
<Button Command="{Binding ChartXOnDroppedCommand}" Content="ChartXOnDropped" Margin="2"/>
<Button Command="{Binding ChartYOnDroppedCommand}" Content="ChartYOnDropped" Margin="2"/>
<Button Command="{Binding ChartSetSymbolPeriodCommand}" Content="ChartSetSymbolPeriod" Margin="2"/>
<Button Command="{Binding ChartScreenShotCommand}" Content="ChartScreenShot" Margin="2"/>
</WrapPanel>
</Grid>
</TabItem>
<TabItem Header="Time and Date">
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding TimeCurrentCommand}" Content="TimeCurrent" Margin="2"/>
<Button Command="{Binding TimeTradeServerCommand}" Content="TimeTradeServer" Margin="2"/>
<Button Command="{Binding TimeLocalCommand}" Content="TimeLocal" Margin="2"/>
<Button Command="{Binding TimeGMTCommand}" Content="TimeGMT" Margin="2"/>
</WrapPanel>
</TabItem>
<ListBox ItemsSource="{Binding TimeSeriesResults}" />
<TabItem Header="Checkup and Common Functions">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid>
</TabItem>
<TabItem Header="Market Info">
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding SymbolsTotalCommand}" Content="SymbolsTotal" Margin="2"/>
<Button Command="{Binding SymbolNameCommand}" Content="SymbolName" Margin="2"/>
<Button Command="{Binding SymbolSelectCommand}" Content="SymbolSelect" Margin="2"/>
<Button Command="{Binding SymbolIsSynchronizedCommand}" Content="SymbolIsSynchronized" Margin="2"/>
<Button Command="{Binding SymbolInfoDoubleCommand}" Content="SymbolInfoDouble" Margin="2"/>
<Button Command="{Binding SymbolInfoIntegerCommand}" Content="SymbolInfoInteger" Margin="2"/>
<Button Command="{Binding SymbolInfoStringCommand}" Content="SymbolInfoString" Margin="2"/>
<Button Command="{Binding SymbolInfoTickCommand}" Content="SymbolInfoTick" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionQuoteCommand}" Content="SymbolInfoSessionQuote" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionTradeCommand}" Content="SymbolInfoSessionTrade" Margin="2"/>
<Button Command="{Binding MarketBookAddCommand}" Content="MarketBookAdd" Margin="2"/>
<Button Command="{Binding MarketBookReleaseCommand}" Content="MarketBookRelease" Margin="2"/>
<Button Command="{Binding MarketBookGetCommand}" Content="MarketBookGet" Margin="2"/>
</WrapPanel>
</TabItem>
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding GetLastErrorCommand}" Content="GetLastError" Margin="2"/>
<Button Command="{Binding ResetLastErrorCommand}" Content="ResetLastError" Margin="2"/>
</WrapPanel>
<TabItem Header="CTrade">
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding PositionOpenCommand}" Content="PositionOpen" Margin="2"/>
</WrapPanel>
</TabItem>
</TabControl>
<Button Grid.Row="1" Content="UnlockTicks" HorizontalAlignment="Left" Margin="5" Command="{Binding UnlockTicksCommand}"/>
<Expander Grid.Row="2" Header="History" IsExpanded="True">
<ListBox mtApi5TestClient:ListBoxBehavior.ScrollOnNewItem="true" Height="200" ItemsSource="{Binding History}"/>
</Expander>
<Grid Margin="10" Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="{Binding MessageText}" Margin="2"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Command="{Binding PrintCommand}" Content="Print" Margin="2" />
<Button Command="{Binding AlertCommand}" Content="Alert" Margin="2" />
</StackPanel>
</Grid>
</Grid>
</TabItem>
<TabItem Header="Global Variables">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Global Variable Name" Margin="2,0,0,0"/>
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding GlobalVarName}" Margin="4,0,0,0"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Global Variable Value" Margin="2,2,0,0"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding GlobalVarValue}" Margin="4,2,0,0"/>
</Grid>
<WrapPanel VerticalAlignment="Top" Grid.Row="1" Margin="0,5,0,0">
<Button Command="{Binding GlobalVariableCheckCommand}" Content="GlobalVariableCheck" Margin="2"/>
<Button Command="{Binding GlobalVariableTimeCommand}" Content="GlobalVariableTime" Margin="2"/>
<Button Command="{Binding GlobalVariableDelCommand}" Content="GlobalVariableDel" Margin="2"/>
<Button Command="{Binding GlobalVariableGetCommand}" Content="GlobalVariableGet" Margin="2"/>
<Button Command="{Binding GlobalVariableNameCommand}" Content="GlobalVariableName" Margin="2"/>
<Button Command="{Binding GlobalVariableSetCommand}" Content="GlobalVariableSet" Margin="2"/>
<Button Command="{Binding GlobalVariablesFlushCommand}" Content="GlobalVariablesFlush" Margin="2"/>
<Button Command="{Binding GlobalVariableTempCommand}" Content="GlobalVariableTemp" Margin="2"/>
<Button Command="{Binding GlobalVariableSetOnConditionCommand}" Content="GlobalVariableSetOnCondition" Margin="2"/>
<Button Command="{Binding GlobalVariablesDeleteAllCommand}" Content="GlobalVariablesDeleteAll" Margin="2"/>
<Button Command="{Binding GlobalVariablesTotalCommand}" Content="GlobalVariablesTotal" Margin="2"/>
</WrapPanel>
</Grid>
</TabItem>
</TabControl>
</Grid>
<GridSplitter Grid.Row="1" Height="2" HorizontalAlignment="Stretch" />
<Border Grid.Row="2" BorderThickness="1" BorderBrush="DarkBlue" Margin="2">
<Grid Margin="3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Output Console" Background="LightYellow" />
<ListBox Grid.Row="1" ItemsSource="{Binding History}"
mtApi5TestClient:ListBoxBehavior.ScrollOnNewItem="true" />
</Grid>
</Border>
<StatusBar Grid.Row="3">
<StatusBarItem>
+12 -17
View File
@@ -1,37 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MtApi5TestClient
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow
{
ViewModel _vm { get; set; }
private ViewModel Vm { get; }
public MainWindow()
{
InitializeComponent();
_vm = new ViewModel();
_MainLayout.DataContext = _vm;
Vm = new ViewModel();
_MainLayout.DataContext = Vm;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
_vm.Close();
Vm.Close();
}
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
var regex = new Regex("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}
}
}
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using MtApi5;
@@ -29,7 +26,7 @@ namespace MtApi5TestClient
}
}
public uint Magic
public ulong Magic
{
get { return TradeRequest.Magic; }
set
@@ -109,7 +106,7 @@ namespace MtApi5TestClient
}
}
public uint Deviation
public ulong Deviation
{
get { return TradeRequest.Deviation; }
set
+14 -19
View File
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel;
namespace MtApi5TestClient
{
@@ -10,38 +6,38 @@ namespace MtApi5TestClient
{
#region Properties
public string Instrument { get; private set; }
public string Instrument { get; }
private double _Bid;
private double _bid;
public double Bid
{
get { return _Bid; }
get { return _bid; }
set
{
_Bid = value;
_bid = value;
OnPropertyChanged("Bid");
}
}
private double _Ask;
private double _ask;
public double Ask
{
get { return _Ask; }
get { return _ask; }
set
{
_Ask = value;
_ask = value;
OnPropertyChanged("Ask");
}
}
private int _FeedCount = 0;
public int FeedCount
private int _expertHandle;
public int ExpertHandle
{
get { return _FeedCount; }
get { return _expertHandle; }
set
{
_FeedCount = value;
OnPropertyChanged("FeedCount");
_expertHandle = value;
OnPropertyChanged("ExpertHandle");
}
}
@@ -59,8 +55,7 @@ namespace MtApi5TestClient
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
@@ -1,21 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MtApi5;
using MtApi5;
using System.ComponentModel;
namespace MtApi5TestClient
{
public class TimeSeriesValueViewModel : INotifyPropertyChanged
{
private string _SymbolValue;
private string _symbolValue;
public string SymbolValue
{
get { return _SymbolValue; }
get { return _symbolValue; }
set
{
_SymbolValue = value;
_symbolValue = value;
OnPropertyChanged("SymbolValue");
}
}
@@ -24,13 +20,36 @@ namespace MtApi5TestClient
public int StartPos { get; set; }
public int Count { get; set; }
private int _indicatorHandle;
public int IndicatorHandle
{
get { return _indicatorHandle; }
set
{
_indicatorHandle = value;
OnPropertyChanged("IndicatorHandle");
}
}
private ENUM_INDICATOR _indicatorType = ENUM_INDICATOR.IND_MACD;
public ENUM_INDICATOR IndicatorType
{
get { return _indicatorType; }
set
{
_indicatorType = value;
OnPropertyChanged("IndicatorType");
}
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
var handler = PropertyChanged;
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
File diff suppressed because it is too large Load Diff
+132 -2
View File
@@ -113,6 +113,13 @@
this.label22 = new System.Windows.Forms.Label();
this.textBoxErrorCode = new System.Windows.Forms.TextBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.button70 = new System.Windows.Forms.Button();
this.label33 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.label31 = new System.Windows.Forms.Label();
this.textBoxAccountHost = new System.Windows.Forms.TextBox();
this.textBoxAccountPassword = new System.Windows.Forms.TextBox();
this.textBoxAccountLogin = new System.Windows.Forms.TextBox();
this.button67 = new System.Windows.Forms.Button();
this.button66 = new System.Windows.Forms.Button();
this.button65 = new System.Windows.Forms.Button();
@@ -136,6 +143,8 @@
this.label23 = new System.Windows.Forms.Label();
this.textBoxAccountInfoSymbol = new System.Windows.Forms.TextBox();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.comboBox12 = new System.Windows.Forms.ComboBox();
this.button72 = new System.Windows.Forms.Button();
this.button36 = new System.Windows.Forms.Button();
this.comboBox10 = new System.Windows.Forms.ComboBox();
this.comboBox9 = new System.Windows.Forms.ComboBox();
@@ -182,6 +191,7 @@
this.button14 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.tabPage7 = new System.Windows.Forms.TabPage();
this.button71 = new System.Windows.Forms.Button();
this.button23 = new System.Windows.Forms.Button();
this.iCustomBtn = new System.Windows.Forms.Button();
this.tabPage8 = new System.Windows.Forms.TabPage();
@@ -202,6 +212,7 @@
this.button4 = new System.Windows.Forms.Button();
this.tabPage11 = new System.Windows.Forms.TabPage();
this.button69 = new System.Windows.Forms.Button();
this.button73 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -1110,6 +1121,13 @@
//
// tabPage3
//
this.tabPage3.Controls.Add(this.button70);
this.tabPage3.Controls.Add(this.label33);
this.tabPage3.Controls.Add(this.label32);
this.tabPage3.Controls.Add(this.label31);
this.tabPage3.Controls.Add(this.textBoxAccountHost);
this.tabPage3.Controls.Add(this.textBoxAccountPassword);
this.tabPage3.Controls.Add(this.textBoxAccountLogin);
this.tabPage3.Controls.Add(this.button67);
this.tabPage3.Controls.Add(this.button66);
this.tabPage3.Controls.Add(this.button65);
@@ -1140,6 +1158,64 @@
this.tabPage3.Text = "Account Information";
this.tabPage3.UseVisualStyleBackColor = true;
//
// button70
//
this.button70.Location = new System.Drawing.Point(371, 292);
this.button70.Name = "button70";
this.button70.Size = new System.Drawing.Size(97, 23);
this.button70.TabIndex = 18;
this.button70.Text = "ChangeAccount";
this.button70.UseVisualStyleBackColor = true;
this.button70.Click += new System.EventHandler(this.button70_Click);
//
// label33
//
this.label33.AutoSize = true;
this.label33.Location = new System.Drawing.Point(168, 269);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(66, 13);
this.label33.TabIndex = 17;
this.label33.Text = "MT4 Server:";
//
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(168, 241);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(56, 13);
this.label32.TabIndex = 17;
this.label32.Text = "Password:";
//
// label31
//
this.label31.AutoSize = true;
this.label31.Location = new System.Drawing.Point(168, 214);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(36, 13);
this.label31.TabIndex = 17;
this.label31.Text = "Login:";
//
// textBoxAccountHost
//
this.textBoxAccountHost.Location = new System.Drawing.Point(234, 266);
this.textBoxAccountHost.Name = "textBoxAccountHost";
this.textBoxAccountHost.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountHost.TabIndex = 17;
//
// textBoxAccountPassword
//
this.textBoxAccountPassword.Location = new System.Drawing.Point(234, 238);
this.textBoxAccountPassword.Name = "textBoxAccountPassword";
this.textBoxAccountPassword.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountPassword.TabIndex = 16;
//
// textBoxAccountLogin
//
this.textBoxAccountLogin.Location = new System.Drawing.Point(232, 212);
this.textBoxAccountLogin.Name = "textBoxAccountLogin";
this.textBoxAccountLogin.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountLogin.TabIndex = 15;
//
// button67
//
this.button67.Location = new System.Drawing.Point(157, 33);
@@ -1354,6 +1430,8 @@
//
// tabPage4
//
this.tabPage4.Controls.Add(this.comboBox12);
this.tabPage4.Controls.Add(this.button72);
this.tabPage4.Controls.Add(this.button36);
this.tabPage4.Controls.Add(this.comboBox10);
this.tabPage4.Controls.Add(this.comboBox9);
@@ -1377,6 +1455,25 @@
this.tabPage4.Text = "MarketInfo";
this.tabPage4.UseVisualStyleBackColor = true;
//
// comboBox12
//
this.comboBox12.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox12.FormattingEnabled = true;
this.comboBox12.Location = new System.Drawing.Point(13, 188);
this.comboBox12.Name = "comboBox12";
this.comboBox12.Size = new System.Drawing.Size(186, 21);
this.comboBox12.TabIndex = 38;
//
// button72
//
this.button72.Location = new System.Drawing.Point(208, 186);
this.button72.Name = "button72";
this.button72.Size = new System.Drawing.Size(111, 23);
this.button72.TabIndex = 37;
this.button72.Text = "TerminalInfoString";
this.button72.UseVisualStyleBackColor = true;
this.button72.Click += new System.EventHandler(this.button72_Click);
//
// button36
//
this.button36.Location = new System.Drawing.Point(208, 157);
@@ -1771,6 +1868,7 @@
//
// tabPage6
//
this.tabPage6.Controls.Add(this.button73);
this.tabPage6.Controls.Add(this.textBoxPrint);
this.tabPage6.Controls.Add(this.button27);
this.tabPage6.Controls.Add(this.button14);
@@ -1785,14 +1883,14 @@
//
// textBoxPrint
//
this.textBoxPrint.Location = new System.Drawing.Point(13, 86);
this.textBoxPrint.Location = new System.Drawing.Point(13, 108);
this.textBoxPrint.Name = "textBoxPrint";
this.textBoxPrint.Size = new System.Drawing.Size(386, 20);
this.textBoxPrint.TabIndex = 3;
//
// button27
//
this.button27.Location = new System.Drawing.Point(405, 84);
this.button27.Location = new System.Drawing.Point(405, 106);
this.button27.Name = "button27";
this.button27.Size = new System.Drawing.Size(75, 23);
this.button27.TabIndex = 2;
@@ -1822,6 +1920,7 @@
//
// tabPage7
//
this.tabPage7.Controls.Add(this.button71);
this.tabPage7.Controls.Add(this.button23);
this.tabPage7.Controls.Add(this.iCustomBtn);
this.tabPage7.Location = new System.Drawing.Point(4, 40);
@@ -1832,6 +1931,16 @@
this.tabPage7.Text = "Technical Indicators";
this.tabPage7.UseVisualStyleBackColor = true;
//
// button71
//
this.button71.Location = new System.Drawing.Point(6, 64);
this.button71.Name = "button71";
this.button71.Size = new System.Drawing.Size(107, 23);
this.button71.TabIndex = 17;
this.button71.Text = "iBarShift";
this.button71.UseVisualStyleBackColor = true;
this.button71.Click += new System.EventHandler(this.button71_Click);
//
// button23
//
this.button23.Location = new System.Drawing.Point(6, 35);
@@ -2062,6 +2171,16 @@
this.button69.UseVisualStyleBackColor = true;
this.button69.Click += new System.EventHandler(this.button69_Click);
//
// button73
//
this.button73.Location = new System.Drawing.Point(13, 74);
this.button73.Name = "button73";
this.button73.Size = new System.Drawing.Size(75, 23);
this.button73.TabIndex = 4;
this.button73.Text = "TimeGMT";
this.button73.UseVisualStyleBackColor = true;
this.button73.Click += new System.EventHandler(this.button73_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2287,6 +2406,17 @@
private System.Windows.Forms.Button button68;
private System.Windows.Forms.TabPage tabPage11;
private System.Windows.Forms.Button button69;
private System.Windows.Forms.Label label33;
private System.Windows.Forms.Label label32;
private System.Windows.Forms.Label label31;
private System.Windows.Forms.TextBox textBoxAccountHost;
private System.Windows.Forms.TextBox textBoxAccountPassword;
private System.Windows.Forms.TextBox textBoxAccountLogin;
private System.Windows.Forms.Button button70;
private System.Windows.Forms.Button button71;
private System.Windows.Forms.ComboBox comboBox12;
private System.Windows.Forms.Button button72;
private System.Windows.Forms.Button button73;
}
}
+76 -1
View File
@@ -34,6 +34,7 @@ namespace TestApiClientUI
comboBox9.DataSource = Enum.GetNames(typeof(EnumTerminalInfoInteger));
comboBox10.DataSource = Enum.GetNames(typeof(EnumTerminalInfoDouble));
comboBox11.DataSource = Enum.GetNames(typeof(EnumObject));
comboBox12.DataSource = Enum.GetNames(typeof(ENUM_TERMINAL_INFO_STRING));
comboBoxAccountInfoCmd.DataSource = Enum.GetNames(typeof(TradeOperation));
_apiClient.QuoteUpdated += apiClient_QuoteUpdated;
@@ -42,6 +43,7 @@ namespace TestApiClientUI
_apiClient.QuoteRemoved += apiClient_QuoteRemoved;
_apiClient.ConnectionStateChanged += apiClient_ConnectionStateChanged;
_apiClient.OnLastTimeBar += _apiClient_OnLastTimeBar;
_apiClient.OnChartEvent += _apiClient_OnChartEvent;
InitOrderCommandsGroup();
@@ -134,7 +136,15 @@ namespace TestApiClientUI
private void _apiClient_OnLastTimeBar(object sender, TimeBarArgs e)
{
var msg =
$"TimeBar: Symbol = {e.TimeBar.Symbol}, OpenTime = {e.TimeBar.OpenTime}, CloseTime = {e.TimeBar.CloseTime}, Open = {e.TimeBar.Open}, Close = {e.TimeBar.Close}, High = {e.TimeBar.High}, Low = {e.TimeBar.Low}";
$"TimeBar: ExpertHandle = {e.ExpertHandle}, Symbol = {e.TimeBar.Symbol}, OpenTime = {e.TimeBar.OpenTime}, CloseTime = {e.TimeBar.CloseTime}, Open = {e.TimeBar.Open}, Close = {e.TimeBar.Close}, High = {e.TimeBar.High}, Low = {e.TimeBar.Low}";
Console.WriteLine(msg);
PrintLog(msg);
}
private void _apiClient_OnChartEvent(object sender, ChartEventArgs e)
{
var msg =
$"OnChartEvent: ExpertHandle = {e.ExpertHandle}, ChartId = {e.ChartId}, EventId = {e.EventId}, Lparam = {e.Lparam}, Dparam = {e.Dparam}, Sparam = {e.Sparam}";
Console.WriteLine(msg);
PrintLog(msg);
}
@@ -606,18 +616,28 @@ namespace TestApiClientUI
listBoxProceHistory.DataSource = items;
}
//TimeCurrent
private void button13_Click(object sender, EventArgs e)
{
var retVal = _apiClient.TimeCurrent();
PrintLog($"TimeCurrent result: {retVal}");
}
//TimeLocal
private void button14_Click(object sender, EventArgs e)
{
var retVal = _apiClient.TimeLocal();
PrintLog($"TimeLocal result: {retVal}");
}
//TimeGMT
private void button73_Click(object sender, EventArgs e)
{
var retVal = _apiClient.TimeGMT();
PrintLog($"TimeGMT result: {retVal}");
}
//RefreshRates
private void buttonRefreshRates_Click(object sender, EventArgs e)
{
var retVal = _apiClient.RefreshRates();
@@ -1120,6 +1140,16 @@ namespace TestApiClientUI
PrintLog($"TerminalInfoDouble: result = {result}");
}
//TerminalInfoString
private async void button72_Click(object sender, EventArgs e)
{
ENUM_TERMINAL_INFO_STRING propId;
Enum.TryParse(comboBox12.Text, out propId);
var result = await Execute(() => _apiClient.TerminalInfoString(propId));
PrintLog($"TerminalInfoString: result = {result}");
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
var checkbox = sender as CheckBox;
@@ -1424,5 +1454,50 @@ namespace TestApiClientUI
{
_apiClient.UnlockTicks();
}
private async void button70_Click(object sender, EventArgs e)
{
var login = textBoxAccountLogin.Text;
var password = textBoxAccountPassword.Text;
var host = textBoxAccountHost.Text;
if (string.IsNullOrEmpty(login))
{
MessageBox.Show(@"Login is not defined!", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
textBoxAccountLogin.Focus();
return;
}
if (string.IsNullOrEmpty(password))
{
MessageBox.Show(@"Password is not defined!", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
textBoxAccountPassword.Focus();
return;
}
if (string.IsNullOrEmpty(host))
{
MessageBox.Show(@"Host is not defined!", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
textBoxAccountHost.Focus();
return;
}
var result = await Execute(() => _apiClient.ChangeAccount(login, password, host));
PrintLog($"ChangeAccount result: {result}");
}
//iBarShift
private async void button71_Click(object sender, EventArgs e)
{
const string symbol = "EURUSD";
const ChartPeriod timeframe = ChartPeriod.PERIOD_D1;
var time1 = _apiClient.TimeCurrent();
var time2 = _apiClient.iTime(symbol, timeframe, 5);
var result1 = await Execute(() => _apiClient.iBarShift(symbol, timeframe, time1, true));
var result2 = await Execute(() => _apiClient.iBarShift(symbol, timeframe, time2, true));
PrintLog($"iBarShift result1 = {result1}, time = {time1}");
PrintLog($"iBarShift result2 = {result2}, time = {time2}");
}
}
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+163
View File
@@ -0,0 +1,163 @@
//+----------------------------------------------------------------------------+
//| mql4-auth.mqh |
//+----------------------------------------------------------------------------+
//| Built by Sergey Lukin |
//| contact@sergeylukin.com |
//+----------------------------------------------------------------------------+
#include <WinUser32.mqh>
#import "user32.dll"
int GetAncestor(int,int);
int GetLastActivePopup(int);
int GetDlgItem(int,int);
int GetParent(int hWnd);
#import
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool loginDialogIsOpen()
{
int hwnd=WindowHandle(Symbol(),Period());
int hMetaTrader,hLoginDialog=0;
// Retrieve Terminal Window Handler
while(!IsStopped())
{
hwnd=GetParent(hwnd);
if(hwnd==0) break;
hMetaTrader=hwnd;
}
hLoginDialog=GetLastActivePopup(hMetaTrader);
if(hLoginDialog!=0)
{
return(true);
} else {
return(false);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void closeLoginDialog()
{
int hwnd=WindowHandle(Symbol(),Period());
int hMetaTrader,hLoginDialog=0,hCancelButton=0;
// Retrieve Terminal Window Handler
while(!IsStopped())
{
hwnd=GetParent(hwnd);
if(hwnd==0) break;
hMetaTrader=hwnd;
}
Sleep(60);
hLoginDialog=GetLastActivePopup(hMetaTrader);
if(hLoginDialog!=0)
{
hCancelButton=GetDlgItem(hLoginDialog,0x2);
if(hCancelButton!=0)
{
// Click "Cancel" button in Login Dialog
PostMessageA(hCancelButton,0x00F5,0,0);
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool auth(string login,string passwd,string server)
{
datetime s=TimeLocal();
int h = 0, e = 0, a = GetAncestor(WindowHandle(Symbol(), NULL), 2);
int i = 0;
PostMessageA(a,WM_COMMAND,35429,0);
while(e==0)
{
// Give us up to a minute to find the Login dialog
if(TimeLocal()-s>60)
{
return(false);
}
h=GetLastActivePopup(a);
// Select login field
e=GetDlgItem(h,0x49d);
Sleep(1);
}
// Press DELETE key many times in login field to remove current value
for(i=1; i<=100; i++)
{
PostMessageA(e,WM_KEYDOWN,0x2E,1);
}
// Iterate over characters in "login" string and pass them to login field one by one
char login_chars[];
string2CharsArray(login,login_chars);
for(i=0; i<ArraySize(login_chars); i++)
{
PostMessageA(e,WM_CHAR,login_chars[i],0);
}
// Select password field
e=GetDlgItem(h,0x4c4);
// Press DELETE key many times in password field to remove current value
for(i=1; i<=100; i++)
{
PostMessageA(e,WM_KEYDOWN,0x2E,1);
}
// Iterate over characters in "passwd" string and pass them to password field one by one
char password_chars[];
string2CharsArray(passwd,password_chars);
for(i=0; i<ArraySize(password_chars); i++)
{
PostMessageA(e,WM_CHAR,password_chars[i],0);
}
// Select server field
e=GetDlgItem(h,0x50d);
// Press DELETE key many times in server field to remove current value
for(i=1; i<=100; i++)
{
PostMessageA(e,WM_KEYDOWN,0x2E,1);
}
// Iterate over characters in "server" string and pass them to server field one by one
char server_chars[];
string2CharsArray(server,server_chars);
for(i=0; i<ArraySize(server_chars); i++)
{
PostMessageA(e,WM_CHAR,server_chars[i],0);
}
Sleep(2*1000);
// Press submit button
e=GetDlgItem(h,0x1);
SendMessageA(e,0x00F5,0,0);
return(true);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
/*
* Iterates over string and puts each character code in array
*/
void string2CharsArray(string myString,char &chars[])
{
int cnt=StringLen(myString);
ArrayResize(chars,cnt);
for(int i=0; i<cnt; i++)
{
chars[i]=StringGetChar(myString,i);
}
}
//+------------------------------------------------------------------+
BIN
View File
Binary file not shown.
Executable → Regular
+7181 -1519
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -257,7 +257,7 @@ public:
{
return (string)_long;
} else {
return (string)_dbl;
return (_dbl!=0) ? (string)_dbl : "0";
}
}
};