mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 11:07:48 +00:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f01ec01a5f | |||
| 0c38d37559 | |||
| 897892dc89 | |||
| 1a5882b75a | |||
| 0f717f1cb7 | |||
| 5d78ad5067 | |||
| 6c45f28a05 | |||
| ca3c0e735f | |||
| f71151104b | |||
| 28816a75ac | |||
| 6023bffed6 | |||
| fd34f009cd | |||
| 1bb2b65cdf | |||
| 37e8275465 | |||
| 52ca4fae1e | |||
| 6b327e017a | |||
| 10a758bd93 | |||
| 4a9642b60c | |||
| 6ba6496e46 | |||
| 1ffbba5ee3 | |||
| 8cdfd6fb91 | |||
| 7c3ddbabac | |||
| 83e0145a3a | |||
| f17c7cd554 | |||
| 4aefdd554b | |||
| 820ed9a631 | |||
| 95c55e90be | |||
| 486a1979a6 | |||
| faef5f7d18 | |||
| bd45c45fa1 | |||
| 29be184136 | |||
| 9bfda95cf7 | |||
| 24b881d8a0 | |||
| 07dd83f890 | |||
| 9afd30e463 | |||
| 16f454ca61 | |||
| f3a3a582fd | |||
| 93aaae86ed | |||
| bce68fd168 | |||
| 0812229538 | |||
| d0fa4af1d0 | |||
| 8eb4bcfabe | |||
| 9ea58354be | |||
| 02774d7328 | |||
| cbff71f8d0 | |||
| 951a91976c | |||
| 6a37826486 | |||
| cab2de6d24 | |||
| ec6c71607b | |||
| 0a39b69b15 | |||
| fe94ec21de | |||
| 34c78c73c0 | |||
| d7b8ef894c |
@@ -164,7 +164,7 @@ _DLLAPI int _stdcall sendStringResponse(int expertHandle, wchar_t* response, wch
|
||||
_DLLAPI int _stdcall sendVoidResponse(int expertHandle, wchar_t* err)
|
||||
{
|
||||
return Execute<int>([&expertHandle]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, nullptr);
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseObject(nullptr));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace MTApiService
|
||||
|
||||
public class LogConfigurator
|
||||
{
|
||||
private const string LogFileNameExtension = "txt";
|
||||
private const string LogFileNameExtension = "log";
|
||||
|
||||
public static void Setup(string profileName)
|
||||
{
|
||||
|
||||
+41
-12
@@ -4,35 +4,51 @@ namespace MTApiService
|
||||
{
|
||||
public class Mt5Expert : MtExpert
|
||||
{
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(MtExpert));
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(Mt5Expert));
|
||||
private const int StopExpertInterval = 2000; // 2 sec for testing mode
|
||||
private readonly System.Timers.Timer _stopTimer = new System.Timers.Timer();
|
||||
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;
|
||||
_stopTimer.Interval = StopExpertInterval;
|
||||
_stopTimer.Elapsed += _stopTimer_Elapsed;
|
||||
}
|
||||
|
||||
public bool IsTestMode { get; }
|
||||
|
||||
public override void UpdateQuote(MtQuote quote)
|
||||
public override int GetCommandType()
|
||||
{
|
||||
Log.Debug("UpdateQuote: begin.");
|
||||
|
||||
base.UpdateQuote(quote);
|
||||
Log.Debug("GetCommandType: called.");
|
||||
|
||||
if (IsTestMode)
|
||||
{
|
||||
//reset timer
|
||||
_stopTimer.Stop();
|
||||
_stopTimer.Start();
|
||||
ResetTestModeTimer();
|
||||
}
|
||||
|
||||
Log.Debug("UpdateQuote: end.");
|
||||
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)
|
||||
@@ -42,7 +58,20 @@ namespace MTApiService
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,7 @@ namespace MTApiService
|
||||
}
|
||||
|
||||
server.AddExpert(expert);
|
||||
expert.Deinited += ExpertOnDeinited;
|
||||
|
||||
Log.Info("AddExpert: end");
|
||||
}
|
||||
@@ -81,7 +82,6 @@ namespace MTApiService
|
||||
if (_experts.ContainsKey(expertHandle))
|
||||
{
|
||||
expert = _experts[expertHandle];
|
||||
_experts.Remove(expertHandle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace MTApiService
|
||||
Log.Debug("SendResponse: end.");
|
||||
}
|
||||
|
||||
public int GetCommandType()
|
||||
public virtual int GetCommandType()
|
||||
{
|
||||
Log.Debug("GetCommandType: called.");
|
||||
|
||||
@@ -110,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);
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace MTApiService
|
||||
Log.Debug("SendEvent: end.");
|
||||
}
|
||||
|
||||
public virtual void UpdateQuote(MtQuote quote)
|
||||
public void UpdateQuote(MtQuote quote)
|
||||
{
|
||||
Log.DebugFormat("UpdateQuote: begin. quote = {0}", quote);
|
||||
|
||||
|
||||
@@ -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.29.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.29.0")]
|
||||
[assembly: AssemblyVersion("1.0.30.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.30.0")]
|
||||
@@ -3,6 +3,9 @@
|
||||
internal enum Mt5EventTypes
|
||||
{
|
||||
OnTradeTransaction = 1,
|
||||
OnBookEvent = 2
|
||||
OnBookEvent = 2,
|
||||
OnTick = 3,
|
||||
OnLastTimeBar = 4,
|
||||
OnLockTicks = 5
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace MtApi5.Events
|
||||
{
|
||||
internal class OnLockTicksEvent
|
||||
{
|
||||
public string Instrument { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,16 @@ namespace MtApi5
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public ENUM_BOOK_TYPE type { get; } // Order type from ENUM_BOOK_TYPE enumeration
|
||||
public double price { get; } // Price
|
||||
public long volume { get; } // 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}|{price}|{volume}";
|
||||
return $"type = {type}; price = {price}; volume = {volume}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-2
@@ -7,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;
|
||||
@@ -21,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
|
||||
|
||||
@@ -4,14 +4,14 @@ namespace MtApi5
|
||||
{
|
||||
public class MqlTradeCheckResult
|
||||
{
|
||||
public uint Retcode { get; } // Reply code
|
||||
public double Balance { get; } // Balance after the execution of the deal
|
||||
public double Equity { get; } // Equity after the execution of the deal
|
||||
public double Profit { get; } // Floating profit
|
||||
public double Margin { get; } // Margin requirements
|
||||
public double Margin_free { get; } // Free margin
|
||||
public double Margin_level { get; } // Margin level
|
||||
public string Comment { get; } // 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
|
||||
@@ -32,6 +32,9 @@ namespace MtApi5
|
||||
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}";
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace MtApi5
|
||||
//OrderSend = 1,
|
||||
OrderCalcMargin = 2,
|
||||
OrderCalcProfit = 3,
|
||||
//OrderCheck = 4,
|
||||
//OrderSendAsync = 5,
|
||||
PositionsTotal = 6,
|
||||
PositionGetSymbol = 7,
|
||||
@@ -17,6 +16,7 @@ namespace MtApi5
|
||||
PositionGetDouble = 9,
|
||||
PositionGetInteger = 10,
|
||||
PositionGetString = 11,
|
||||
PositionGetTicket = 4,
|
||||
OrdersTotal = 12,
|
||||
OrderGetTicket = 13,
|
||||
OrderSelect = 14,
|
||||
@@ -107,8 +107,6 @@ namespace MtApi5
|
||||
BacktestingReady = 66,
|
||||
IsTesting = 67,
|
||||
|
||||
Print = 68,
|
||||
|
||||
//Requests
|
||||
MtRequest = 155,
|
||||
|
||||
@@ -179,6 +177,80 @@ namespace MtApi5
|
||||
TimeLocal = 129,
|
||||
TimeGMT = 130,
|
||||
|
||||
IndicatorRelease = 131
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
+91
-2
@@ -36,6 +36,96 @@ namespace MtApi5
|
||||
#endregion //Chart Timeframes
|
||||
|
||||
|
||||
#region Charts Properties
|
||||
|
||||
public enum ENUM_CHART_PROPERTY_DOUBLE
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
public enum ENUM_CHART_PROPERTY_INTEGER
|
||||
{
|
||||
CHART_SHOW = 46,
|
||||
CHART_IS_OBJECT = 111,
|
||||
CHART_BRING_TO_TOP = 35,
|
||||
CHART_CONTEXT_MENU = 50,
|
||||
CHART_CROSSHAIR_TOOL = 49,
|
||||
CHART_MOUSE_SCROLL = 42,
|
||||
CHART_EVENT_MOUSE_WHEEL = 48,
|
||||
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_KEYBOARD_CONTROL = 47,
|
||||
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_SHOW_ONE_CLICK = 44,
|
||||
CHART_IS_MAXIMIZED = 115,
|
||||
CHART_IS_MINIMIZED = 116
|
||||
}
|
||||
|
||||
public enum ENUM_CHART_PROPERTY_STRING
|
||||
{
|
||||
CHART_COMMENT = 20,
|
||||
CHART_EXPERT_NAME = 113,
|
||||
CHART_SCRIPT_NAME = 114
|
||||
}
|
||||
|
||||
public enum ENUM_CHART_POSITION
|
||||
{
|
||||
CHART_BEGIN = 0, // Chart beginning (the oldest prices)
|
||||
CHART_CURRENT_POS = 1, // Current position
|
||||
CHART_END = 2 // Chart end (the latest prices)
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Environment State:
|
||||
|
||||
#region Client Terminal Properties
|
||||
@@ -91,8 +181,7 @@ namespace MtApi5
|
||||
SYMBOL_BACKGROUND_COLOR = 79,
|
||||
SYMBOL_CHART_MODE = 80,
|
||||
SYMBOL_SELECT = 0,
|
||||
//FIXME: SYMBOL_VISIBLE not found in MQL5 environment!
|
||||
//SYMBOL_VISIBLE = ?
|
||||
SYMBOL_VISIBLE = 76,
|
||||
SYMBOL_SESSION_DEALS = 56,
|
||||
SYMBOL_SESSION_BUY_ORDERS = 60,
|
||||
SYMBOL_SESSION_SELL_ORDERS = 62,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5LockTicksEventArgs : EventArgs
|
||||
{
|
||||
internal Mt5LockTicksEventArgs(string symbol)
|
||||
{
|
||||
Symbol = symbol;
|
||||
}
|
||||
|
||||
public string Symbol { get; }
|
||||
}
|
||||
}
|
||||
+17
-2
@@ -1,16 +1,31 @@
|
||||
namespace MtApi5
|
||||
using System;
|
||||
using MTApiService;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5Quote
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,13 @@ namespace MtApi5
|
||||
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
||||
}
|
||||
|
||||
public static int ConvertToMtTime(DateTime time)
|
||||
public static int ConvertToMtTime(DateTime? time)
|
||||
{
|
||||
var result = 0;
|
||||
if (time == DateTime.MinValue) return result;
|
||||
if (time == null || time == DateTime.MinValue)
|
||||
return result;
|
||||
var tmpTime = new DateTime(1970, 1, 1);
|
||||
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,12 @@
|
||||
<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" />
|
||||
@@ -73,6 +78,10 @@
|
||||
<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" />
|
||||
@@ -80,11 +89,15 @@
|
||||
<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="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">
|
||||
|
||||
+783
-25
@@ -40,12 +40,21 @@ namespace MtApi5
|
||||
private volatile bool _isBacktestingMode;
|
||||
private Mt5ConnectionState _connectionState = Mt5ConnectionState.Disconnected;
|
||||
private int _executorHandle;
|
||||
private readonly Dictionary<Mt5EventTypes, Action<int, string>> _mtEventHandlers =
|
||||
new Dictionary<Mt5EventTypes, Action<int, string>>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
public MtApi5Client()
|
||||
{
|
||||
LogConfigurator.Setup(LogProfileName);
|
||||
|
||||
_mtEventHandlers[Mt5EventTypes.OnBookEvent] = ReceivedOnBookEvent;
|
||||
_mtEventHandlers[Mt5EventTypes.OnTick] = ReceivedOnTickEvent;
|
||||
_mtEventHandlers[Mt5EventTypes.OnTradeTransaction] = ReceivedOnTradeTransactionEvent;
|
||||
_mtEventHandlers[Mt5EventTypes.OnLastTimeBar] = ReceivedOnLastTimeBarEvent;
|
||||
_mtEventHandlers[Mt5EventTypes.OnLockTicks] = ReceivedOnLockTicksEvent;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -82,7 +91,7 @@ namespace MtApi5
|
||||
{
|
||||
var client = Client;
|
||||
var quotes = client?.GetQuotes();
|
||||
return quotes?.Select(q => q.Convert());
|
||||
return quotes?.Select(q => new Mt5Quote(q));
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -280,6 +289,17 @@ namespace MtApi5
|
||||
return SendCommand<string>(Mt5CommandType.PositionGetString, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the ticket of a position with the specified index in the list of open positions and automatically selects the position to work with using functions PositionGetDouble, PositionGetInteger, PositionGetString.
|
||||
///</summary>
|
||||
///<param name="index">Identifier of a position property.</param>
|
||||
public ulong PositionGetTicket(int index)
|
||||
{
|
||||
var commandParameters = new ArrayList { index };
|
||||
|
||||
return SendCommand<ulong>(Mt5CommandType.PositionGetTicket, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the number of current orders.
|
||||
///</summary>
|
||||
@@ -501,11 +521,20 @@ namespace MtApi5
|
||||
///<summary>
|
||||
///Close all open positions.
|
||||
///</summary>
|
||||
[Obsolete("OrderCloseAll is deprecated, please use PositionCloseAll instead.")]
|
||||
public bool OrderCloseAll()
|
||||
{
|
||||
return SendCommand<bool>(Mt5CommandType.OrderCloseAll, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Close all open positions. Returns count of closed positions.
|
||||
///</summary>
|
||||
public int PositionCloseAll()
|
||||
{
|
||||
return SendCommand<int>(Mt5CommandType.PositionCloseAll, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Closes a position with the specified ticket.
|
||||
///</summary>
|
||||
@@ -518,6 +547,36 @@ namespace MtApi5
|
||||
return SendCommand<bool>(Mt5CommandType.PositionClose, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Closes a position with the specified ticket.
|
||||
///</summary>
|
||||
///<param name="ticket">Ticket of the closed position.</param>
|
||||
///<param name="deviation">Maximal deviation from the current price (in points).</param>
|
||||
/// <param name="result">output result</param>
|
||||
public bool PositionClose(ulong ticket, ulong deviation, out MqlTradeResult result)
|
||||
{
|
||||
Log.Debug($"PositionClose: ticket = {ticket}, deviation = {deviation}");
|
||||
|
||||
var response = SendRequest<PositionCloseResult>(new PositionCloseRequest
|
||||
{
|
||||
Ticket = ticket,
|
||||
Deviation = deviation
|
||||
});
|
||||
|
||||
result = response?.TradeResult;
|
||||
return response != null && response.RetVal;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Closes a position with the specified ticket.
|
||||
///</summary>
|
||||
///<param name="ticket">Ticket of the closed position.</param>
|
||||
/// <param name="result">output result</param>
|
||||
public bool PositionClose(ulong ticket, out MqlTradeResult result)
|
||||
{
|
||||
return PositionClose(ticket, ulong.MaxValue, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a position with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -548,7 +607,7 @@ namespace MtApi5
|
||||
/// <param name="comment">comment</param>
|
||||
/// <param name="result">output result</param>
|
||||
/// <returns>true - successful check of the basic structures, otherwise - false.</returns>
|
||||
public bool PositionOpen(string symbol, ENUM_ORDER_TYPE orderType, double volume, double price, double sl, double tp, string comment , out MqlTradeResult result)
|
||||
public bool PositionOpen(string symbol, ENUM_ORDER_TYPE orderType, double volume, double price, double sl, double tp, string comment, out MqlTradeResult result)
|
||||
{
|
||||
Log.Debug($"PositionOpen: symbol = {symbol}, orderType = {orderType}, volume = {volume}, price = {price}, sl = {sl}, tp = {tp}, comment = {comment}");
|
||||
|
||||
@@ -566,6 +625,22 @@ namespace MtApi5
|
||||
result = response?.TradeResult;
|
||||
return response != null && response.RetVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a position with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="symbol">symbol</param>
|
||||
/// <param name="orderType">order type to open position </param>
|
||||
/// <param name="volume">position volume</param>
|
||||
/// <param name="price">execution price</param>
|
||||
/// <param name="sl">Stop Loss price</param>
|
||||
/// <param name="tp">Take Profit price</param>
|
||||
/// <param name="result">output result</param>
|
||||
/// <returns>true - successful check of the basic structures, otherwise - false.</returns>
|
||||
public bool PositionOpen(string symbol, ENUM_ORDER_TYPE orderType, double volume, double price, double sl, double tp, out MqlTradeResult result)
|
||||
{
|
||||
return PositionOpen(symbol, orderType, volume, price, sl, tp, "", out result);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Account Information functions
|
||||
@@ -611,11 +686,11 @@ namespace MtApi5
|
||||
///<param name="symbolName">Symbol name.</param>
|
||||
///<param name="timeframe"> Period.</param>
|
||||
///<param name="propId">Identifier of the requested property, value of the ENUM_SERIES_INFO_INTEGER enumeration.</param>
|
||||
public int SeriesInfoInteger(string symbolName, ENUM_TIMEFRAMES timeframe, ENUM_SERIES_INFO_INTEGER propId)
|
||||
public long SeriesInfoInteger(string symbolName, ENUM_TIMEFRAMES timeframe, ENUM_SERIES_INFO_INTEGER propId)
|
||||
{
|
||||
var commandParameters = new ArrayList { symbolName, (int)timeframe, (int)propId };
|
||||
|
||||
return SendCommand<int>(Mt5CommandType.SeriesInfoInteger, commandParameters);
|
||||
return SendCommand<long>(Mt5CommandType.SeriesInfoInteger, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -723,7 +798,7 @@ namespace MtApi5
|
||||
ratesArray = new MqlRates[retVal.Length];
|
||||
for(var i = 0; i < retVal.Length; i++)
|
||||
{
|
||||
ratesArray[i] = new MqlRates(Mt5TimeConverter.ConvertFromMtTime(retVal[i].time)
|
||||
ratesArray[i] = new MqlRates(retVal[i].time
|
||||
, retVal[i].open
|
||||
, retVal[i].high
|
||||
, retVal[i].low
|
||||
@@ -757,7 +832,7 @@ namespace MtApi5
|
||||
ratesArray = new MqlRates[retVal.Length];
|
||||
for (var i = 0; i < retVal.Length; i++)
|
||||
{
|
||||
ratesArray[i] = new MqlRates(Mt5TimeConverter.ConvertFromMtTime(retVal[i].time)
|
||||
ratesArray[i] = new MqlRates(retVal[i].time
|
||||
, retVal[i].open
|
||||
, retVal[i].high
|
||||
, retVal[i].low
|
||||
@@ -791,7 +866,7 @@ namespace MtApi5
|
||||
ratesArray = new MqlRates[retVal.Length];
|
||||
for (var i = 0; i < retVal.Length; i++)
|
||||
{
|
||||
ratesArray[i] = new MqlRates(Mt5TimeConverter.ConvertFromMtTime(retVal[i].time)
|
||||
ratesArray[i] = new MqlRates(retVal[i].time
|
||||
, retVal[i].open
|
||||
, retVal[i].high
|
||||
, retVal[i].low
|
||||
@@ -1375,6 +1450,23 @@ namespace MtApi5
|
||||
return SendCommand<string>(Mt5CommandType.SymbolInfoString, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the corresponding property of a specified symbol.
|
||||
///</summary>
|
||||
///<param name="symbolName">Symbol name.</param>
|
||||
///<param name="propId">Identifier of a symbol property.</param>
|
||||
///<param name="value">Variable of the string type receiving the value of the requested property.</param>
|
||||
public bool SymbolInfoString(string symbolName, ENUM_SYMBOL_INFO_STRING propId, out string value)
|
||||
{
|
||||
var response = SendRequest<SymbolInfoStringResult>(new SymbolInfoStringRequest
|
||||
{
|
||||
SymbolName = symbolName,
|
||||
PropId = propId
|
||||
});
|
||||
|
||||
value = response?.StringVar;
|
||||
return response?.RetVal ?? false;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns current prices of a specified symbol in a variable of the MqlTick type.
|
||||
@@ -1472,17 +1564,515 @@ namespace MtApi5
|
||||
|
||||
#endregion
|
||||
|
||||
#region Chart Operations
|
||||
|
||||
///<summary>
|
||||
///Returns the ID of the current chart.
|
||||
///</summary>
|
||||
///<returns>
|
||||
/// Value of long type.
|
||||
///</returns>
|
||||
public long ChartId()
|
||||
{
|
||||
return SendCommand<long>(Mt5CommandType.ChartId, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///This function calls a forced redrawing of a specified chart.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart ID. 0 means the current chart.</param>
|
||||
public void ChartRedraw(long chartId = 0)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId };
|
||||
SendCommand<object>(Mt5CommandType.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>(Mt5CommandType.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>(Mt5CommandType.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>(Mt5CommandType.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 result = SendRequest<ChartTimePriceToXyResult>(new ChartTimePriceToXyRequest
|
||||
{
|
||||
ChartId = chartId,
|
||||
SubWindow = subWindow,
|
||||
Time = time,
|
||||
Price = price
|
||||
});
|
||||
|
||||
x = result?.X ?? 0;
|
||||
y = result?.Y ?? 0;
|
||||
return result?.RetVal ?? false;
|
||||
}
|
||||
|
||||
///<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 result = SendRequest<ChartXyToTimePriceResult>(new ChartXyToTimePriceRequest
|
||||
{
|
||||
ChartId = chartId,
|
||||
X = x,
|
||||
Y = y
|
||||
});
|
||||
|
||||
subWindow = result?.SubWindow ?? 0;
|
||||
time = result?.Time;
|
||||
price = result?.Price ?? double.NaN;
|
||||
return result?.RetVal ?? false;
|
||||
}
|
||||
|
||||
///<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>(Mt5CommandType.ChartOpen, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the ID of the first chart of the client terminal.
|
||||
///</summary>
|
||||
public long ChartFirst()
|
||||
{
|
||||
return SendCommand<long>(Mt5CommandType.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>(Mt5CommandType.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 = 0)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId };
|
||||
return SendCommand<bool>(Mt5CommandType.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>(Mt5CommandType.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>(Mt5CommandType.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, ENUM_CHART_PROPERTY_DOUBLE propId, double value)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, (int)propId, value };
|
||||
return SendCommand<bool>(Mt5CommandType.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, ENUM_CHART_PROPERTY_INTEGER propId, long value)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, (int)propId, value };
|
||||
return SendCommand<bool>(Mt5CommandType.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, ENUM_CHART_PROPERTY_STRING propId, string value)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, (int)propId, value };
|
||||
return SendCommand<bool>(Mt5CommandType.ChartSetString, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the specified chart. Chart property must be of double 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, ENUM_CHART_PROPERTY_DOUBLE propId, int subWindow = 0)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, (int)propId, subWindow };
|
||||
return SendCommand<double>(Mt5CommandType.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, ENUM_CHART_PROPERTY_INTEGER propId, int subWindow = 0)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, (int)propId, subWindow };
|
||||
return SendCommand<long>(Mt5CommandType.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, ENUM_CHART_PROPERTY_STRING propId)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, (int)propId };
|
||||
return SendCommand<string>(Mt5CommandType.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, ENUM_CHART_POSITION position, int shift = 0)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, (int)position, shift };
|
||||
return SendCommand<bool>(Mt5CommandType.ChartNavigate, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Adds an indicator with the specified handle into a specified chart window. Indicator and chart should be generated on the same symbol and time frame.
|
||||
///</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="indicatorHandle">The handle of the indicator.</param>
|
||||
///<returns>
|
||||
///The function returns true in case of success, otherwise it returns false.
|
||||
///</returns>
|
||||
public bool ChartIndicatorAdd(long chartId, int subWindow, int indicatorHandle)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, subWindow, indicatorHandle };
|
||||
return SendCommand<bool>(Mt5CommandType.ChartIndicatorAdd, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Removes an indicator with a specified name from 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="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 in case of successful deletion of the indicator.
|
||||
///</returns>
|
||||
public bool ChartIndicatorDelete(long chartId, int subWindow, string indicatorShortname)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, subWindow, indicatorShortname };
|
||||
return SendCommand<bool>(Mt5CommandType.ChartIndicatorDelete, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the handle of the indicator with the specified short name in 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="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 an indicator handle if successful, otherwise returns INVALID_HANDLE.
|
||||
///</returns>
|
||||
public int ChartIndicatorGet(long chartId, int subWindow, string indicatorShortname)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, subWindow, indicatorShortname };
|
||||
return SendCommand<int>(Mt5CommandType.ChartIndicatorGet, 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>(Mt5CommandType.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>(Mt5CommandType.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>(Mt5CommandType.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>(Mt5CommandType.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>(Mt5CommandType.ChartTimeOnDropped, null);
|
||||
return Mt5TimeConverter.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>(Mt5CommandType.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>(Mt5CommandType.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>(Mt5CommandType.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, ENUM_ALIGN_MODE alignMode = ENUM_ALIGN_MODE.ALIGN_RIGHT)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, filename, width, height, (int)alignMode };
|
||||
return SendCommand<bool>(Mt5CommandType.ChartScreenShot, commandParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands of Terminal
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql5 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_STRING enumeration.</param>
|
||||
///<returns>
|
||||
///Value of string type.
|
||||
///</returns>
|
||||
public string TerminalInfoString(ENUM_TERMINAL_INFO_STRING propertyId)
|
||||
{
|
||||
var commandParameters = new ArrayList { (int)propertyId };
|
||||
return SendCommand<string>(Mt5CommandType.TerminalInfoString, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql5 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_INTEGER enumeration.</param>
|
||||
///<returns>
|
||||
///Value of int type.
|
||||
///</returns>
|
||||
public int TerminalInfoInteger(ENUM_TERMINAL_INFO_INTEGER propertyId)
|
||||
{
|
||||
var commandParameters = new ArrayList { (int)propertyId };
|
||||
return SendCommand<int>(Mt5CommandType.TerminalInfoInteger, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql5 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_DOUBLE enumeration.</param>
|
||||
///<returns>
|
||||
///Value of double type.
|
||||
///</returns>
|
||||
public double TerminalInfoDouble(ENUM_TERMINAL_INFO_DOUBLE propertyId)
|
||||
{
|
||||
var commandParameters = new ArrayList { (int)propertyId };
|
||||
return SendCommand<double>(Mt5CommandType.TerminalInfoDouble, commandParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Common Functions
|
||||
|
||||
///<summary>
|
||||
///It enters a message in the Expert Advisor log.
|
||||
///</summary>
|
||||
///<param name="message">Symbol name.</param>
|
||||
///<param name="message">Message</param>
|
||||
public bool Print(string message)
|
||||
{
|
||||
var commandParameters = new ArrayList { message };
|
||||
|
||||
return SendCommand<bool>(Mt5CommandType.Print, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Displays a message in a separate window.
|
||||
///</summary>
|
||||
///<param name="message">Message</param>
|
||||
public void Alert(string message)
|
||||
{
|
||||
var commandParameters = new ArrayList { message };
|
||||
SendCommand<object>(Mt5CommandType.Alert, commandParameters);
|
||||
}
|
||||
|
||||
#endregion // Common Functions
|
||||
|
||||
#region Object Functions
|
||||
@@ -2341,6 +2931,155 @@ namespace MtApi5
|
||||
|
||||
#endregion //Date and Time
|
||||
|
||||
#region Checkup
|
||||
|
||||
///<summary>
|
||||
///Returns the value of the last error that occurred during the execution of an mql5 program.
|
||||
///</summary>
|
||||
public int GetLastError()
|
||||
{
|
||||
return SendCommand<int>(Mt5CommandType.GetLastError, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Sets the value of the predefined variable _LastError into zero.
|
||||
///</summary>
|
||||
public void ResetLastError()
|
||||
{
|
||||
SendCommand<object>(Mt5CommandType.ResetLastError, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Global Variables
|
||||
|
||||
///<summary>
|
||||
///Checks the existence of a global variable with the specified name.
|
||||
///</summary>
|
||||
///<param name="name">Global variable name.</param>
|
||||
public bool GlobalVariableCheck(string name)
|
||||
{
|
||||
var commandParameters = new ArrayList { name };
|
||||
return SendCommand<bool>(Mt5CommandType.GlobalVariableCheck, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the time when the global variable was last accessed.
|
||||
///</summary>
|
||||
///<param name="name">Name of the global variable.</param>
|
||||
public DateTime GlobalVariableTime(string name)
|
||||
{
|
||||
var commandParameters = new ArrayList { name };
|
||||
var res = SendCommand<int>(Mt5CommandType.GlobalVariableTime, commandParameters);
|
||||
return Mt5TimeConverter.ConvertFromMtTime(res);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Deletes a global variable from the client terminal.
|
||||
///</summary>
|
||||
///<param name="name">Name of the global variable.</param>
|
||||
public bool GlobalVariableDel(string name)
|
||||
{
|
||||
var commandParameters = new ArrayList { name };
|
||||
return SendCommand<bool>(Mt5CommandType.GlobalVariableDel, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of an existing global variable of the client terminal.
|
||||
///</summary>
|
||||
///<param name="name">Global variable name.</param>
|
||||
public double GlobalVariableGet(string name)
|
||||
{
|
||||
var commandParameters = new ArrayList { name };
|
||||
return SendCommand<double>(Mt5CommandType.GlobalVariableGet, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the name of a global variable by its ordinal number.
|
||||
///</summary>
|
||||
///<param name="index">Sequence number in the list of global variables. It should be greater than or equal to 0 and less than GlobalVariablesTotal().</param>
|
||||
public string GlobalVariableName(int index)
|
||||
{
|
||||
var commandParameters = new ArrayList { index };
|
||||
return SendCommand<string>(Mt5CommandType.GlobalVariableName, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Sets a new value for a global variable. If the variable does not exist, the system creates a new global variable.
|
||||
///</summary>
|
||||
///<param name="name">Global variable name.</param>
|
||||
///<param name="value">The new numerical value.</param>
|
||||
public DateTime GlobalVariableSet(string name, double value)
|
||||
{
|
||||
var commandParameters = new ArrayList { name, value };
|
||||
var res = SendCommand<int>(Mt5CommandType.GlobalVariableSet, commandParameters);
|
||||
return Mt5TimeConverter.ConvertFromMtTime(res);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Forcibly saves contents of all global variables to a disk.
|
||||
///</summary>
|
||||
public void GlobalVariablesFlush()
|
||||
{
|
||||
SendCommand<object>(Mt5CommandType.GlobalVariablesFlush, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function attempts to create a temporary global variable. If the variable doesn't exist, the system creates a new temporary global variable.
|
||||
///</summary>
|
||||
///<param name="name">The name of a temporary global variable.</param>
|
||||
public bool GlobalVariableTemp(string name)
|
||||
{
|
||||
var commandParameters = new ArrayList { name };
|
||||
return SendCommand<bool>(Mt5CommandType.GlobalVariableTemp, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Sets the new value of the existing global variable if the current value equals to the third parameter check_value. If there is no global variable, the function will generate an error ERR_GLOBALVARIABLE_NOT_FOUND (4501) and return false.
|
||||
///</summary>
|
||||
///<param name="name">The name of a global variable.</param>
|
||||
///<param name="value">New value.</param>
|
||||
///<param name="checkValue">The value to check the current value of the global variable.</param>
|
||||
public bool GlobalVariableSetOnCondition(string name, double value, double checkValue)
|
||||
{
|
||||
var commandParameters = new ArrayList { name, value, checkValue };
|
||||
return SendCommand<bool>(Mt5CommandType.GlobalVariableSetOnCondition, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Deletes global variables of the client terminal.
|
||||
///</summary>
|
||||
///<param name="prefixName">Name prefix global variables to remove. If you specify a prefix NULL or empty string, then all variables that meet the data criterion will be deleted.</param>
|
||||
///<param name="limitData">Date to select global variables by the time of their last modification. The function removes global variables, which were changed before this date. If the parameter is zero, then all variables that meet the first criterion (prefix) are deleted.</param>
|
||||
public int GlobalVariablesDeleteAll(string prefixName = "", DateTime? limitData = null)
|
||||
{
|
||||
if (prefixName == null)
|
||||
prefixName = "";
|
||||
var commandParameters = new ArrayList { prefixName, Mt5TimeConverter.ConvertToMtTime(limitData) };
|
||||
return SendCommand<int>(Mt5CommandType.GlobalVariablesDeleteAll, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the total number of global variables of the client terminal.
|
||||
///</summary>
|
||||
public int GlobalVariablesTotal()
|
||||
{
|
||||
return SendCommand<int>(Mt5CommandType.GlobalVariablesTotal, null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Backtesting functions
|
||||
|
||||
///<summary>
|
||||
///The function unlock ticks in backtesting mode.
|
||||
///</summary>
|
||||
public void UnlockTicks()
|
||||
{
|
||||
SendCommand<object>(Mt5CommandType.UnlockTicks, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Public Methods
|
||||
|
||||
#region Properties
|
||||
@@ -2388,6 +3127,8 @@ namespace MtApi5
|
||||
public event EventHandler<Mt5ConnectionEventArgs> ConnectionStateChanged;
|
||||
public event EventHandler<Mt5TradeTransactionEventArgs> OnTradeTransaction;
|
||||
public event EventHandler<Mt5BookEventArgs> OnBookEvent;
|
||||
public event EventHandler<Mt5TimeBarArgs> OnLastTimeBar;
|
||||
public event EventHandler<Mt5LockTicksEventArgs> OnLockTicks;
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
@@ -2456,24 +3197,14 @@ namespace MtApi5
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void _client_MtEventReceived(MtEvent e)
|
||||
{
|
||||
var eventType = (Mt5EventTypes)e.EventType;
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case Mt5EventTypes.OnTradeTransaction:
|
||||
ReceivedOnTradeTransaction(e.ExpertHandle, e.Payload);
|
||||
break;
|
||||
case Mt5EventTypes.OnBookEvent:
|
||||
ReceivedOnBookEvent(e.ExpertHandle, e.Payload);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
_mtEventHandlers[eventType](e.ExpertHandle, e.Payload);
|
||||
}
|
||||
|
||||
private void ReceivedOnTradeTransaction(int expertHandler, string payload)
|
||||
private void ReceivedOnTradeTransactionEvent(int expertHandler, string payload)
|
||||
{
|
||||
var e = JsonConvert.DeserializeObject<OnTradeTransactionEvent>(payload);
|
||||
OnTradeTransaction?.Invoke(this, new Mt5TradeTransactionEventArgs
|
||||
@@ -2495,6 +3226,33 @@ namespace MtApi5
|
||||
});
|
||||
}
|
||||
|
||||
private void ReceivedOnTickEvent(int expertHandler, string payload)
|
||||
{
|
||||
var e = JsonConvert.DeserializeObject<OnTickEvent>(payload);
|
||||
var quote = new Mt5Quote(e.Instrument, e.Tick.bid, e.Tick.ask)
|
||||
{
|
||||
ExpertHandle = expertHandler,
|
||||
Volume = e.Tick.volume,
|
||||
Time = e.Tick.time,
|
||||
Last = e.Tick.last
|
||||
};
|
||||
|
||||
QuoteUpdated?.Invoke(this, quote.Instrument, quote.Bid, quote.Ask);
|
||||
QuoteUpdate?.Invoke(this, new Mt5QuoteEventArgs(quote));
|
||||
}
|
||||
|
||||
private void ReceivedOnLastTimeBarEvent(int expertHandler, string payload)
|
||||
{
|
||||
var e = JsonConvert.DeserializeObject<OnLastTimeBarEvent>(payload);
|
||||
OnLastTimeBar?.Invoke(this, new Mt5TimeBarArgs(expertHandler, e.Instrument, e.Rates));
|
||||
}
|
||||
|
||||
private void ReceivedOnLockTicksEvent(int expertHandler, string payload)
|
||||
{
|
||||
var e = JsonConvert.DeserializeObject<OnLockTicksEvent>(payload);
|
||||
OnLockTicks?.Invoke(this, new Mt5LockTicksEventArgs(e.Instrument));
|
||||
}
|
||||
|
||||
private void Connect(string host, int port)
|
||||
{
|
||||
var client = new MtClient(host, port);
|
||||
@@ -2608,7 +3366,7 @@ namespace MtApi5
|
||||
private void _client_QuoteUpdated(MtQuote quote)
|
||||
{
|
||||
if (quote == null) return;
|
||||
QuoteUpdate?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask)));
|
||||
QuoteUpdate?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote)));
|
||||
QuoteUpdated?.Invoke(this, quote.Instrument, quote.Bid, quote.Ask);
|
||||
}
|
||||
|
||||
@@ -2626,7 +3384,7 @@ namespace MtApi5
|
||||
{
|
||||
if (quote != null)
|
||||
{
|
||||
QuoteRemoved?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask)));
|
||||
QuoteRemoved?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2634,7 +3392,7 @@ namespace MtApi5
|
||||
{
|
||||
if (quote != null)
|
||||
{
|
||||
QuoteAdded?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask)));
|
||||
QuoteAdded?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,6 @@ namespace MtApi5
|
||||
private static readonly MtLog Log = LogConfigurator.GetLogger(typeof(MtConverters));
|
||||
|
||||
#region Values Converters
|
||||
public static Mt5Quote Convert(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 double result)
|
||||
{
|
||||
|
||||
@@ -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.17")]
|
||||
[assembly: AssemblyFileVersion("1.0.17")]
|
||||
[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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class PositionCloseResult
|
||||
{
|
||||
public bool RetVal { get; set; }
|
||||
public MqlTradeResult TradeResult { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,17 @@ namespace MtApi5.Requests
|
||||
{
|
||||
internal enum RequestType
|
||||
{
|
||||
Unknown = 0,
|
||||
CopyTicks = 1,
|
||||
iCustom = 2,
|
||||
OrderSend = 3,
|
||||
PositionOpen = 4,
|
||||
OrderCheck = 5,
|
||||
MarketBookGet = 6,
|
||||
IndicatorCreate = 7
|
||||
Unknown = 0,
|
||||
CopyTicks = 1,
|
||||
iCustom = 2,
|
||||
OrderSend = 3,
|
||||
PositionOpen = 4,
|
||||
OrderCheck = 5,
|
||||
MarketBookGet = 6,
|
||||
IndicatorCreate = 7,
|
||||
SymbolInfoString = 8,
|
||||
ChartTimePriceToXY = 9,
|
||||
ChartXYToTimePrice = 10,
|
||||
PositionClose = 11
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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="700"
|
||||
Title="MainWindow" Height="700" Width="900"
|
||||
Closing="Window_Closing">
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="ConnectionTextBlockTemplate" DataType="{x:Type mtapi5:Mt5ConnectionState}">
|
||||
@@ -78,6 +78,28 @@
|
||||
</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>
|
||||
@@ -95,9 +117,9 @@
|
||||
|
||||
<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>
|
||||
|
||||
@@ -107,336 +129,530 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid>
|
||||
<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>
|
||||
<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"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1"
|
||||
Margin="5,0,0,0"
|
||||
Text="{Binding Host, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<Border Grid.Row="3" Margin="2" Visibility="Visible" BorderThickness="1" BorderBrush="DarkBlue">
|
||||
<Grid Margin="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<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>
|
||||
</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.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"/>
|
||||
<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="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"/>
|
||||
</StackPanel>
|
||||
<ListBox Grid.Column="0" ItemsSource="{Binding TimeSeriesResults}" />
|
||||
|
||||
<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>
|
||||
</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>
|
||||
|
||||
<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 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" 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"/>
|
||||
</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.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>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<TabItem Header="Checkup and Common Functions">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<WrapPanel VerticalAlignment="Top" Margin="5">
|
||||
<Button Command="{Binding GetLastErrorCommand}" Content="GetLastError" Margin="2"/>
|
||||
<Button Command="{Binding ResetLastErrorCommand}" Content="ResetLastError" Margin="2"/>
|
||||
</WrapPanel>
|
||||
|
||||
<Button Grid.Row="1" Content="UnlockTicks" HorizontalAlignment="Left" Margin="5" Command="{Binding UnlockTicksCommand}"/>
|
||||
|
||||
<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>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ComboBox Grid.Row="0" Grid.Column="0"
|
||||
ItemsSource="{Binding Source={StaticResource ENUM_INDICATOR_Key}}"
|
||||
SelectedItem="{Binding TimeSeriesValues.IndicatorType}"/>
|
||||
<Button Grid.Row="0" Grid.Column="1" Command="{Binding IndicatorCreateCommand}" Margin="2"
|
||||
Content="IndicatorCreate" HorizontalAlignment="Left" />
|
||||
<Label Grid.Row="1" Grid.Column="0" Content="Indicator handle:" Margin="2"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="0" Margin="2" Width="30" PreviewTextInput="NumberValidationTextBox" Text="{Binding TimeSeriesValues.IndicatorHandle}"></TextBox>
|
||||
<Button Grid.Row="1" Grid.Column="1" Command="{Binding IndicatorReleaseCommand}" Margin="2"
|
||||
Content="IndicatorRelease" HorizontalAlignment="Left" />
|
||||
<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>
|
||||
|
||||
<ListBox Grid.Column="0" ItemsSource="{Binding TimeSeriesResults}" />
|
||||
</Grid>
|
||||
|
||||
</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>
|
||||
<GridSplitter Grid.Row="1" Height="2" HorizontalAlignment="Stretch" />
|
||||
|
||||
<TabItem Header="CTrade">
|
||||
<WrapPanel VerticalAlignment="Top" Margin="5">
|
||||
<Button Command="{Binding PositionOpenCommand}" Content="PositionOpen" Margin="2"/>
|
||||
</WrapPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Indicators">
|
||||
<WrapPanel VerticalAlignment="Top" Margin="5">
|
||||
<Button Command="{Binding iCustomCommand}" Content="iCustom" Margin="2"/>
|
||||
</WrapPanel>
|
||||
</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>
|
||||
</TabControl>
|
||||
|
||||
<Expander Grid.Row="2" Header="Console" IsExpanded="True">
|
||||
<ListBox mtApi5TestClient:ListBoxBehavior.ScrollOnNewItem="true" Height="180" ItemsSource="{Binding History}"/>
|
||||
</Expander>
|
||||
<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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ using MtApi5;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace MtApi5TestClient
|
||||
{
|
||||
@@ -18,6 +20,7 @@ namespace MtApi5TestClient
|
||||
|
||||
public DelegateCommand OrderSendCommand { get; private set; }
|
||||
public DelegateCommand OrderCheckCommand { get; private set; }
|
||||
public DelegateCommand PositionGetTicketCommand { get; private set; }
|
||||
|
||||
public DelegateCommand HistoryOrderGetIntegerCommand { get; private set; }
|
||||
public DelegateCommand HistoryDealGetDoubleCommand { get; private set; }
|
||||
@@ -29,6 +32,10 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand AccountInfoIntegerCommand { get; private set; }
|
||||
public DelegateCommand AccountInfoStringCommand { get; private set; }
|
||||
|
||||
public DelegateCommand TerminalInfoDoubleCommand { get; private set; }
|
||||
public DelegateCommand TerminalInfoIntegerCommand { get; private set; }
|
||||
public DelegateCommand TerminalInfoStringCommand { get; private set; }
|
||||
|
||||
public DelegateCommand CopyRatesCommand { get; private set; }
|
||||
public DelegateCommand CopyTimesCommand { get; private set; }
|
||||
public DelegateCommand CopyOpenCommand { get; private set; }
|
||||
@@ -50,6 +57,7 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand SymbolInfoDoubleCommand { get; private set; }
|
||||
public DelegateCommand SymbolInfoIntegerCommand { get; private set; }
|
||||
public DelegateCommand SymbolInfoStringCommand { get; private set; }
|
||||
public DelegateCommand SymbolInfoString2Command { get; private set; }
|
||||
public DelegateCommand SymbolInfoTickCommand { get; private set; }
|
||||
public DelegateCommand SymbolInfoSessionQuoteCommand { get; private set; }
|
||||
public DelegateCommand SymbolInfoSessionTradeCommand { get; private set; }
|
||||
@@ -58,15 +66,64 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand MarketBookGetCommand { get; private set; }
|
||||
|
||||
public DelegateCommand PositionOpenCommand { get; private set; }
|
||||
public DelegateCommand PositionCloseCommand { get; private set; }
|
||||
public DelegateCommand PositionCloseAllCommand { get; private set; }
|
||||
|
||||
public DelegateCommand GetLastErrorCommand { get; private set; }
|
||||
public DelegateCommand ResetLastErrorCommand { get; private set; }
|
||||
public DelegateCommand PrintCommand { get; private set; }
|
||||
public DelegateCommand AlertCommand { get; private set; }
|
||||
|
||||
public DelegateCommand iCustomCommand { get; private set; }
|
||||
|
||||
public DelegateCommand TimeCurrentCommand { get; private set; }
|
||||
|
||||
public DelegateCommand ChartOpenCommand { get; private set; }
|
||||
public DelegateCommand ChartTimePriceToXYCommand { get; private set; }
|
||||
public DelegateCommand ChartXYToTimePriceCommand { get; private set; }
|
||||
public DelegateCommand ChartApplyTemplateCommand { get; private set; }
|
||||
public DelegateCommand ChartSaveTemplateCommand { get; private set; }
|
||||
public DelegateCommand ChartIdCommand { get; private set; }
|
||||
public DelegateCommand ChartRedrawCommand { get; private set; }
|
||||
public DelegateCommand ChartWindowFindCommand { get; private set; }
|
||||
public DelegateCommand ChartCloseCommand { get; private set; }
|
||||
public DelegateCommand ChartPeriodCommand { get; private set; }
|
||||
public DelegateCommand ChartSetDoubleCommand { get; private set; }
|
||||
public DelegateCommand ChartSetIntegerCommand { get; private set; }
|
||||
public DelegateCommand ChartSetStringCommand { get; private set; }
|
||||
public DelegateCommand ChartGetDoubleCommand { get; private set; }
|
||||
public DelegateCommand ChartGetIntegerCommand { get; private set; }
|
||||
public DelegateCommand ChartNavigateCommand { get; private set; }
|
||||
public DelegateCommand ChartIndicatorAddCommand { get; private set; }
|
||||
public DelegateCommand ChartIndicatorDeleteCommand { get; private set; }
|
||||
public DelegateCommand ChartIndicatorGetCommand { get; private set; }
|
||||
public DelegateCommand ChartIndicatorNameCommand { get; private set; }
|
||||
public DelegateCommand ChartIndicatorsTotalCommand { get; private set; }
|
||||
public DelegateCommand ChartWindowOnDroppedCommand { get; private set; }
|
||||
public DelegateCommand ChartPriceOnDroppedCommand { get; private set; }
|
||||
public DelegateCommand ChartTimeOnDroppedCommand { get; private set; }
|
||||
public DelegateCommand ChartXOnDroppedCommand { get; private set; }
|
||||
public DelegateCommand ChartYOnDroppedCommand { get; private set; }
|
||||
public DelegateCommand ChartSetSymbolPeriodCommand { get; private set; }
|
||||
public DelegateCommand ChartScreenShotCommand { get; private set; }
|
||||
|
||||
public DelegateCommand TimeTradeServerCommand { get; private set; }
|
||||
public DelegateCommand TimeLocalCommand { get; private set; }
|
||||
public DelegateCommand TimeGMTCommand { get; private set; }
|
||||
|
||||
public DelegateCommand GlobalVariableCheckCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariableTimeCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariableDelCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariableGetCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariableNameCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariableSetCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariablesFlushCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariableTempCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariableSetOnConditionCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariablesDeleteAllCommand { get; private set; }
|
||||
public DelegateCommand GlobalVariablesTotalCommand { get; private set; }
|
||||
|
||||
public DelegateCommand UnlockTicksCommand { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -147,6 +204,11 @@ namespace MtApi5TestClient
|
||||
public ENUM_ACCOUNT_INFO_INTEGER AccountInfoIntegerPropertyId { get; set; }
|
||||
public ENUM_ACCOUNT_INFO_STRING AccountInfoStringPropertyId { get; set; }
|
||||
|
||||
public ENUM_TERMINAL_INFO_DOUBLE TerminalInfoDoublePropertyId { get; set; }
|
||||
public ENUM_TERMINAL_INFO_INTEGER TerminalInfoIntegerPropertyId { get; set; }
|
||||
public ENUM_TERMINAL_INFO_STRING TerminalInfoStringPropertyId { get; set; }
|
||||
|
||||
|
||||
public TimeSeriesValueViewModel TimeSeriesValues { get; set; }
|
||||
|
||||
public ObservableCollection<string> TimeSeriesResults { get; } = new ObservableCollection<string>();
|
||||
@@ -162,6 +224,60 @@ namespace MtApi5TestClient
|
||||
}
|
||||
}
|
||||
|
||||
private string _chartFunctionsSymbolValue = "EURUSD";
|
||||
public string ChartFunctionsSymbolValue
|
||||
{
|
||||
get { return _chartFunctionsSymbolValue; }
|
||||
set
|
||||
{
|
||||
_chartFunctionsSymbolValue = value;
|
||||
OnPropertyChanged("ChartFunctionsSymbolValue");
|
||||
}
|
||||
}
|
||||
|
||||
private long _chartFunctionsChartIdValue;
|
||||
public long ChartFunctionsChartIdValue
|
||||
{
|
||||
get { return _chartFunctionsChartIdValue; }
|
||||
set
|
||||
{
|
||||
_chartFunctionsChartIdValue = value;
|
||||
OnPropertyChanged("ChartFunctionsChartIdValue");
|
||||
}
|
||||
}
|
||||
|
||||
private string _globalVarName;
|
||||
public string GlobalVarName
|
||||
{
|
||||
get { return _globalVarName; }
|
||||
set
|
||||
{
|
||||
_globalVarName = value;
|
||||
OnPropertyChanged("GlobalVarName");
|
||||
}
|
||||
}
|
||||
|
||||
private double _globalVarValue;
|
||||
public double GlobalVarValue
|
||||
{
|
||||
get { return _globalVarValue; }
|
||||
set
|
||||
{
|
||||
_globalVarValue = value;
|
||||
OnPropertyChanged("GlobalVarValue");
|
||||
}
|
||||
}
|
||||
|
||||
private ulong _positionTicketValue;
|
||||
public ulong PositionTicketValue
|
||||
{
|
||||
get { return _positionTicketValue; }
|
||||
set
|
||||
{
|
||||
_positionTicketValue = value;
|
||||
OnPropertyChanged("PositionTicketValue");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
@@ -173,11 +289,11 @@ namespace MtApi5TestClient
|
||||
_mtApiClient.ConnectionStateChanged += mMtApiClient_ConnectionStateChanged;
|
||||
_mtApiClient.QuoteAdded += mMtApiClient_QuoteAdded;
|
||||
_mtApiClient.QuoteRemoved += mMtApiClient_QuoteRemoved;
|
||||
_mtApiClient.QuoteUpdated += mMtApiClient_QuoteUpdated;
|
||||
_mtApiClient.QuoteUpdate += mMtApiClient_QuoteUpdate;
|
||||
_mtApiClient.OnTradeTransaction += mMtApiClient_OnTradeTransaction;
|
||||
_mtApiClient.OnBookEvent += _mtApiClient_OnBookEvent;
|
||||
|
||||
_quotesMap = new Dictionary<string, QuoteViewModel>();
|
||||
_mtApiClient.OnLastTimeBar += _mtApiClient_OnLastTimeBar;
|
||||
_mtApiClient.OnLockTicks += _mtApiClient_OnLockTicks;
|
||||
|
||||
ConnectionState = _mtApiClient.ConnectionState;
|
||||
ConnectionMessage = "Disconnected";
|
||||
@@ -213,6 +329,7 @@ namespace MtApi5TestClient
|
||||
|
||||
OrderSendCommand = new DelegateCommand(ExecuteOrderSend);
|
||||
OrderCheckCommand = new DelegateCommand(ExecuteOrderCheck);
|
||||
PositionGetTicketCommand = new DelegateCommand(ExecutePositionGetTicket);
|
||||
|
||||
HistoryOrderGetIntegerCommand = new DelegateCommand(ExecuteHistoryOrderGetInteger);
|
||||
HistoryDealGetDoubleCommand = new DelegateCommand(ExecuteHistoryDealGetDouble);
|
||||
@@ -224,6 +341,10 @@ namespace MtApi5TestClient
|
||||
AccountInfoIntegerCommand = new DelegateCommand(ExecuteAccountInfoInteger);
|
||||
AccountInfoStringCommand = new DelegateCommand(ExecuteAccountInfoString);
|
||||
|
||||
TerminalInfoDoubleCommand = new DelegateCommand(ExecuteTerminalInfoDouble);
|
||||
TerminalInfoIntegerCommand = new DelegateCommand(ExecuteTerminalInfoInteger);
|
||||
TerminalInfoStringCommand = new DelegateCommand(ExecuteTerminalInfoString);
|
||||
|
||||
CopyRatesCommand = new DelegateCommand(ExecuteCopyRates);
|
||||
CopyTimesCommand = new DelegateCommand(ExecuteCopyTime);
|
||||
CopyOpenCommand = new DelegateCommand(ExecuteCopyOpen);
|
||||
@@ -245,6 +366,7 @@ namespace MtApi5TestClient
|
||||
SymbolInfoDoubleCommand = new DelegateCommand(ExecuteSymbolInfoDouble);
|
||||
SymbolInfoIntegerCommand = new DelegateCommand(ExecuteSymbolInfoInteger);
|
||||
SymbolInfoStringCommand = new DelegateCommand(ExecuteSymbolInfoString);
|
||||
SymbolInfoString2Command = new DelegateCommand(ExecuteSymbolInfoString2);
|
||||
SymbolInfoTickCommand = new DelegateCommand(ExecuteSymbolInfoTick);
|
||||
SymbolInfoSessionQuoteCommand = new DelegateCommand(ExecuteSymbolInfoSessionQuote);
|
||||
SymbolInfoSessionTradeCommand = new DelegateCommand(ExecuteSymbolInfoSessionTrade);
|
||||
@@ -253,15 +375,63 @@ namespace MtApi5TestClient
|
||||
MarketBookGetCommand = new DelegateCommand(ExecuteMarketBookGet);
|
||||
|
||||
PositionOpenCommand = new DelegateCommand(ExecutePositionOpen);
|
||||
PositionCloseCommand = new DelegateCommand(ExecutePositionClose);
|
||||
PositionCloseAllCommand = new DelegateCommand(ExecutePositionCloseAll);
|
||||
|
||||
PrintCommand = new DelegateCommand(ExecutePrint);
|
||||
AlertCommand = new DelegateCommand(ExecuteAlert);
|
||||
GetLastErrorCommand = new DelegateCommand(ExecuteGetLastError);
|
||||
ResetLastErrorCommand = new DelegateCommand(ExecuteResetLastError);
|
||||
|
||||
iCustomCommand = new DelegateCommand(ExecuteICustom);
|
||||
|
||||
ChartOpenCommand = new DelegateCommand(ExecuteChartOpen);
|
||||
ChartTimePriceToXYCommand = new DelegateCommand(ExecuteChartTimePriceToXY);
|
||||
ChartXYToTimePriceCommand = new DelegateCommand(ExecuteChartXYToTimePrice);
|
||||
ChartApplyTemplateCommand = new DelegateCommand(ExecuteChartApplyTemplate);
|
||||
ChartSaveTemplateCommand = new DelegateCommand(ExecuteChartSaveTemplate);
|
||||
ChartIdCommand = new DelegateCommand(ExecuteChartId);
|
||||
ChartRedrawCommand = new DelegateCommand(ExecuteChartRedraw);
|
||||
ChartWindowFindCommand = new DelegateCommand(ExecuteChartWindowFind);
|
||||
ChartCloseCommand = new DelegateCommand(ExecuteChartClose);
|
||||
ChartPeriodCommand = new DelegateCommand(ExecuteChartPeriod);
|
||||
ChartSetDoubleCommand = new DelegateCommand(ExecuteChartSetDouble);
|
||||
ChartSetIntegerCommand = new DelegateCommand(ExecuteChartSetInteger);
|
||||
ChartSetStringCommand = new DelegateCommand(ExecuteChartSetString);
|
||||
ChartGetDoubleCommand = new DelegateCommand(ExecuteChartGetDouble);
|
||||
ChartGetIntegerCommand = new DelegateCommand(ExecuteChartGetInteger);
|
||||
ChartNavigateCommand = new DelegateCommand(ExecuteChartNavigate);
|
||||
ChartIndicatorAddCommand = new DelegateCommand(ExecuteChartIndicatorAdd);
|
||||
ChartIndicatorDeleteCommand = new DelegateCommand(ExecuteChartIndicatorDelete);
|
||||
ChartIndicatorGetCommand = new DelegateCommand(ExecuteChartIndicatorGet);
|
||||
ChartIndicatorNameCommand = new DelegateCommand(ExecuteChartIndicatorName);
|
||||
ChartIndicatorsTotalCommand = new DelegateCommand(ExecuteChartIndicatorsTotal);
|
||||
ChartWindowOnDroppedCommand = new DelegateCommand(ExecuteChartWindowOnDropped);
|
||||
ChartPriceOnDroppedCommand = new DelegateCommand(ExecuteChartPriceOnDropped);
|
||||
ChartTimeOnDroppedCommand = new DelegateCommand(ExecuteChartTimeOnDropped);
|
||||
ChartXOnDroppedCommand = new DelegateCommand(ExecuteChartXOnDropped);
|
||||
ChartYOnDroppedCommand = new DelegateCommand(ExecuteChartYOnDropped);
|
||||
ChartSetSymbolPeriodCommand = new DelegateCommand(ExecuteChartSetSymbolPeriod);
|
||||
ChartScreenShotCommand = new DelegateCommand(ExecuteChartScreenShot);
|
||||
|
||||
TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
|
||||
TimeTradeServerCommand = new DelegateCommand(ExecuteTimeTradeServer);
|
||||
TimeLocalCommand = new DelegateCommand(ExecuteTimeLocal);
|
||||
TimeGMTCommand = new DelegateCommand(ExecuteTimeGMT);
|
||||
|
||||
GlobalVariableCheckCommand = new DelegateCommand(ExecuteGlobalVariableCheck);
|
||||
GlobalVariableTimeCommand = new DelegateCommand(ExecuteGlobalVariableTime);
|
||||
GlobalVariableDelCommand = new DelegateCommand(ExecuteGlobalVariableDel);
|
||||
GlobalVariableGetCommand = new DelegateCommand(ExecuteGlobalVariableGet);
|
||||
GlobalVariableNameCommand = new DelegateCommand(ExecuteGlobalVariableName);
|
||||
GlobalVariableSetCommand = new DelegateCommand(ExecuteGlobalVariableSet);
|
||||
GlobalVariablesFlushCommand = new DelegateCommand(ExecuteGlobalVariablesFlush);
|
||||
GlobalVariableTempCommand = new DelegateCommand(ExecuteGlobalVariableTemp);
|
||||
GlobalVariableSetOnConditionCommand = new DelegateCommand(ExecuteGlobalVariableSetOnCondition);
|
||||
GlobalVariablesDeleteAllCommand = new DelegateCommand(ExecuteGlobalVariablesDeleteAll);
|
||||
GlobalVariablesTotalCommand = new DelegateCommand(ExecuteGlobalVariablesTotal);
|
||||
|
||||
UnlockTicksCommand = new DelegateCommand(ExecuteUnlockTicks);
|
||||
}
|
||||
|
||||
private bool CanExecuteConnect(object o)
|
||||
@@ -320,6 +490,19 @@ namespace MtApi5TestClient
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecutePositionGetTicket(object obj)
|
||||
{
|
||||
const int index = 0;
|
||||
var retVal = await Execute(() =>
|
||||
{
|
||||
var ok = _mtApiClient.PositionGetTicket(index);
|
||||
return ok;
|
||||
});
|
||||
|
||||
var message = $"PositionGetTicket: result = {retVal}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecuteHistoryOrderGetInteger(object o)
|
||||
{
|
||||
const ulong ticket = 12345;
|
||||
@@ -391,7 +574,7 @@ namespace MtApi5TestClient
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.AccountInfoInteger(AccountInfoIntegerPropertyId));
|
||||
|
||||
var message = $"AccountInfoInteger: property_id = {AccountInfoDoublePropertyId}; result = {result}";
|
||||
var message = $"AccountInfoInteger: property_id = {AccountInfoIntegerPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
@@ -399,10 +582,35 @@ namespace MtApi5TestClient
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.AccountInfoString(AccountInfoStringPropertyId));
|
||||
|
||||
var message = $"AccountInfoString: property_id = {AccountInfoDoublePropertyId}; result = {result}";
|
||||
var message = $"AccountInfoString: property_id = {AccountInfoStringPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecuteTerminalInfoDouble(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.TerminalInfoDouble(TerminalInfoDoublePropertyId));
|
||||
|
||||
var message = $"TerminalInfoDouble: property_id = {TerminalInfoDoublePropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecuteTerminalInfoInteger(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.TerminalInfoInteger(TerminalInfoIntegerPropertyId));
|
||||
|
||||
var message = $"TerminalInfoInteger: property_id = {TerminalInfoIntegerPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecuteTerminalInfoString(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.TerminalInfoString(TerminalInfoStringPropertyId));
|
||||
|
||||
var message = $"TerminalInfoString: property_id = {TerminalInfoStringPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
|
||||
private async void ExecuteCopyTime(object o)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TimeSeriesValues?.SymbolValue)) return;
|
||||
@@ -620,7 +828,7 @@ namespace MtApi5TestClient
|
||||
foreach (var rates in result)
|
||||
{
|
||||
TimeSeriesResults.Add(
|
||||
$"time={rates.time}; open={rates.open}; high={rates.high}; low={rates.low}; close={rates.close}; tick_volume={rates.tick_volume}; spread={rates.spread}; real_volume={rates.tick_volume}");
|
||||
$"time={rates.time}; mt_time={rates.mt_time}; open={rates.open}; high={rates.high}; low={rates.low}; close={rates.close}; tick_volume={rates.tick_volume}; spread={rates.spread}; real_volume={rates.tick_volume}");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -798,6 +1006,14 @@ namespace MtApi5TestClient
|
||||
AddLog($"SymbolInfoString(EURUSD, ENUM_SYMBOL_INFO_STRING.SYMBOL_DESCRIPTION): result = {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteSymbolInfoString2(object o)
|
||||
{
|
||||
string stringVar = null;
|
||||
|
||||
var retVal = await Execute(() => _mtApiClient.SymbolInfoString("EURUSD", ENUM_SYMBOL_INFO_STRING.SYMBOL_DESCRIPTION, out stringVar));
|
||||
AddLog($"SymbolInfoString-2 (EURUSD, ENUM_SYMBOL_INFO_STRING.SYMBOL_DESCRIPTION): result = {retVal}, stringVar = {stringVar}");
|
||||
}
|
||||
|
||||
private async void ExecuteSymbolInfoTick(object o)
|
||||
{
|
||||
var result = await Execute(() =>
|
||||
@@ -903,6 +1119,21 @@ namespace MtApi5TestClient
|
||||
AddLog($"PositionOpen: symbol EURUSD retVal = {retVal}, result = {tradeResult}");
|
||||
}
|
||||
|
||||
private async void ExecutePositionClose(object obj)
|
||||
{
|
||||
var ticket = PositionTicketValue;
|
||||
MqlTradeResult tradeResult = null;
|
||||
|
||||
var retVal = await Execute(() => _mtApiClient.PositionClose(ticket, out tradeResult));
|
||||
AddLog($"PositionClose: ticket {ticket} retVal = {retVal}, result = {tradeResult}");
|
||||
}
|
||||
|
||||
private async void ExecutePositionCloseAll(object obj)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.PositionCloseAll());
|
||||
AddLog($"PositionCloseAll: count = {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecutePrint(object obj)
|
||||
{
|
||||
var message = MessageText;
|
||||
@@ -911,6 +1142,26 @@ namespace MtApi5TestClient
|
||||
AddLog($"Print: message print in MetaTrader - {retVal}");
|
||||
}
|
||||
|
||||
private void ExecuteAlert(object obj)
|
||||
{
|
||||
var message = MessageText;
|
||||
|
||||
_mtApiClient.Alert(message);
|
||||
AddLog($"Alert: send alert to MetaTrader - {message}.");
|
||||
}
|
||||
|
||||
private async void ExecuteGetLastError(object obj)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.GetLastError());
|
||||
AddLog($"GetLastError: last error = {retVal}");
|
||||
}
|
||||
|
||||
private void ExecuteResetLastError(object obj)
|
||||
{
|
||||
_mtApiClient.ResetLastError();
|
||||
AddLog("ResetLastError: executed.");
|
||||
}
|
||||
|
||||
private async void ExecuteICustom(object o)
|
||||
{
|
||||
const string symbol = "EURUSD";
|
||||
@@ -946,6 +1197,392 @@ namespace MtApi5TestClient
|
||||
AddLog($"TimeGMT: {retVal}");
|
||||
}
|
||||
|
||||
#region Global Variable Commands
|
||||
private async void ExecuteGlobalVariableCheck(object obj)
|
||||
{
|
||||
var name = GlobalVarName;
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableCheck(name));
|
||||
AddLog($"GlobalVariableCheck: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariableTime(object obj)
|
||||
{
|
||||
var name = GlobalVarName;
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableTime(name));
|
||||
AddLog($"GlobalVariableTime: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariableDel(object obj)
|
||||
{
|
||||
var name = GlobalVarName;
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableDel(name));
|
||||
AddLog($"GlobalVariableDel: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariableGet(object obj)
|
||||
{
|
||||
var name = GlobalVarName;
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableGet(name));
|
||||
GlobalVarValue = retVal;
|
||||
AddLog($"GlobalVariableGet: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariableName(object obj)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableName(0));
|
||||
GlobalVarName = retVal;
|
||||
AddLog($"GlobalVariableName: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariableSet(object obj)
|
||||
{
|
||||
var name = GlobalVarName;
|
||||
var value = GlobalVarValue;
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableSet(name, value));
|
||||
AddLog($"GlobalVariableSet: {retVal}");
|
||||
}
|
||||
|
||||
private void ExecuteGlobalVariablesFlush(object obj)
|
||||
{
|
||||
_mtApiClient.GlobalVariablesFlush();
|
||||
AddLog("GlobalVariablesFlush: executed.");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariableTemp(object obj)
|
||||
{
|
||||
var name = GlobalVarName;
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableTemp(name));
|
||||
AddLog($"GlobalVariableTemp: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariableSetOnCondition(object obj)
|
||||
{
|
||||
var name = GlobalVarName;
|
||||
var value = GlobalVarValue;
|
||||
const double checkValue = 2;
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariableSetOnCondition(name, value, checkValue));
|
||||
AddLog($"GlobalVariableSetOnCondition: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariablesDeleteAll(object obj)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariablesDeleteAll());
|
||||
AddLog($"GlobalVariablesDeleteAll: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteGlobalVariablesTotal(object obj)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.GlobalVariablesTotal());
|
||||
AddLog($"GlobalVariablesTotal: {retVal}");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Chart Commands
|
||||
private async void ExecuteChartOpen(object o)
|
||||
{
|
||||
AddLog("Executed #1");
|
||||
if (string.IsNullOrEmpty(ChartFunctionsSymbolValue))
|
||||
{
|
||||
AddLog("ChartOpen [ERROR]: Symbol is not defined!");
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog($"Executed #2 s:{ChartFunctionsSymbolValue}");
|
||||
|
||||
|
||||
var result = await Execute(() =>
|
||||
{
|
||||
var SymbolAddReturn = _mtApiClient.SymbolSelect(ChartFunctionsSymbolValue, true);
|
||||
var ChartId = _mtApiClient.ChartOpen(ChartFunctionsSymbolValue, TimeSeriesValues.TimeFrame);
|
||||
return ChartId;
|
||||
});
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
AddLog("ChartOpen: result is null");
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog($"ChartOpen: success chartid=>{result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartTimePriceToXY(object o)
|
||||
{
|
||||
const long chartId = 0;
|
||||
const int subWindow = 0;
|
||||
var time = DateTime.Now;
|
||||
const double price = 1.131;
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
var result = await Execute(() => _mtApiClient.ChartTimePriceToXY(chartId, subWindow, time, price, out x, out y));
|
||||
if (result == false)
|
||||
{
|
||||
AddLog("ChartTimePriceToXY: result is false");
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog($"ChartTimePriceToXY: success. x = {x}; Y = {y}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartXYToTimePrice(object o)
|
||||
{
|
||||
const long chartId = 0;
|
||||
const int x = 0;
|
||||
const int y = 0;
|
||||
|
||||
var subWindow = 0;
|
||||
DateTime? time = null;
|
||||
double price = double.NaN;
|
||||
|
||||
var result = await Execute(() => _mtApiClient.ChartXYToTimePrice(chartId, x, y, out subWindow, out time, out price));
|
||||
if (result == false)
|
||||
{
|
||||
AddLog("ChartXYToTimePrice: result is false");
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog($"ChartXYToTimePrice: success. subWindow = {subWindow}; time = {time}; price = {price}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartApplyTemplate(object o)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TimeSeriesValues?.SymbolValue)) return;
|
||||
|
||||
AddLog($"ExecuteChartApplyTemplate #2 s:{TimeSeriesValues?.SymbolValue}");
|
||||
|
||||
|
||||
var result = await Execute(() =>
|
||||
{
|
||||
var SymbolAddReturn = _mtApiClient.SymbolSelect(TimeSeriesValues?.SymbolValue, true);
|
||||
var ChartId = _mtApiClient.ChartOpen(TimeSeriesValues?.SymbolValue, TimeSeriesValues.TimeFrame);
|
||||
|
||||
var MT5Path = _mtApiClient.TerminalInfoString(ENUM_TERMINAL_INFO_STRING.TERMINAL_DATA_PATH);
|
||||
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Filter = "Template File (*.tpl)|*.tpl|All files (*.*)|*.*";
|
||||
if (openFileDialog.ShowDialog() == true)
|
||||
{
|
||||
var TemplateName = "\\Files\\mt5api_copy.tpl";
|
||||
var TemplateStringContent = File.ReadAllLines(openFileDialog.FileName);
|
||||
var DestPath = $"{MT5Path}\\MQL5{TemplateName}";
|
||||
File.WriteAllLines($"{MT5Path}\\MQL5{TemplateName}", TemplateStringContent);
|
||||
_mtApiClient.ChartApplyTemplate(ChartId, TemplateName);
|
||||
}
|
||||
return ChartId;
|
||||
});
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
AddLog("ExecuteChartApplyTemplate: result is null");
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog($"ExecuteChartApplyTemplate: success chartid=>{result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartSaveTemplate(object o)
|
||||
{
|
||||
|
||||
AddLog("ExecuteSaveApplyTemplate #1");
|
||||
|
||||
|
||||
var result = await Execute(() =>
|
||||
{
|
||||
|
||||
var MT5Path = _mtApiClient.TerminalInfoString(ENUM_TERMINAL_INFO_STRING.TERMINAL_DATA_PATH);
|
||||
int ChartId = 0; // Actual Chart
|
||||
var TemplateName = "\\Files\\exported.tpl";
|
||||
_mtApiClient.ChartSaveTemplate(ChartId, TemplateName);
|
||||
var DestPath = $"{MT5Path}\\MQL5{TemplateName}";
|
||||
AddLog($"Destination: {TemplateName}");
|
||||
return ChartId;
|
||||
});
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
AddLog("ChartOpen: result is null");
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog($"ChartOpen: success chartid=>{result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartId(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.ChartId());
|
||||
RunOnUiThread(() =>
|
||||
{
|
||||
ChartFunctionsChartIdValue = result;
|
||||
});
|
||||
AddLog($"ChartId: chartid = {result}");
|
||||
}
|
||||
|
||||
private void ExecuteChartRedraw(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
_mtApiClient.ChartRedraw(chartId);
|
||||
AddLog($"ChartRedraw: executed for chartid = {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartWindowFind(object o)
|
||||
{
|
||||
const string shortname = "MACD(12,26,9)";
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartWindowFind(chartId, shortname));
|
||||
AddLog($"ChartRedraw: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartClose(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartClose(chartId));
|
||||
AddLog($"ChartClose: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartPeriod(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartPeriod(chartId));
|
||||
AddLog($"ChartPeriod: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartSetDouble(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartSetDouble(chartId, ENUM_CHART_PROPERTY_DOUBLE.CHART_PRICE_MAX, 1.13));
|
||||
AddLog($"ChartSetDouble: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartSetInteger(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartSetInteger(chartId, ENUM_CHART_PROPERTY_INTEGER.CHART_SHOW_GRID, 0));
|
||||
AddLog($"ChartSetInteger: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartSetString(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartSetString(chartId, ENUM_CHART_PROPERTY_STRING.CHART_COMMENT, "This is test comment from MtApi5"));
|
||||
AddLog($"ChartSetString: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartGetDouble(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartGetDouble(chartId, ENUM_CHART_PROPERTY_DOUBLE.CHART_PRICE_MAX, 0));
|
||||
AddLog($"ChartGetDouble: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartGetInteger(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartGetInteger(chartId, ENUM_CHART_PROPERTY_INTEGER.CHART_VISIBLE_BARS, 0));
|
||||
AddLog($"ChartGetInteger: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartNavigate(object o)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartNavigate(chartId, ENUM_CHART_POSITION.CHART_BEGIN, 0));
|
||||
AddLog($"ChartNavigate: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartIndicatorAdd(object obj)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var symbol = ChartFunctionsSymbolValue;
|
||||
|
||||
var indicatorHandle = await Execute(() => _mtApiClient.iMACD(symbol, ENUM_TIMEFRAMES.PERIOD_CURRENT, 12, 26, 9, ENUM_APPLIED_PRICE.PRICE_CLOSE));
|
||||
var result = await Execute(() => _mtApiClient.ChartIndicatorAdd(chartId, 1, indicatorHandle));
|
||||
AddLog($"ChartIndicatorAdd: result {result} for chartid {chartId} with indicator {indicatorHandle}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartIndicatorDelete(object o)
|
||||
{
|
||||
const string shortname = "MACD(12,26,9)";
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartIndicatorDelete(chartId, 1, shortname));
|
||||
AddLog($"ChartIndicatorDelete: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartIndicatorGet(object obj)
|
||||
{
|
||||
const string shortname = "MACD(12,26,9)";
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartIndicatorGet(chartId, 1, shortname));
|
||||
AddLog($"hartIndicatorGet: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartIndicatorName(object obj)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartIndicatorName(chartId, 1, 0));
|
||||
AddLog($"ChartIndicatorName: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartIndicatorsTotal(object obj)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartIndicatorsTotal(chartId, 1));
|
||||
AddLog($"ChartIndicatorsTotal: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartWindowOnDropped(object obj)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.ChartWindowOnDropped());
|
||||
AddLog($"ChartWindowOnDropped: result {result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartPriceOnDropped(object obj)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.ChartPriceOnDropped());
|
||||
AddLog($"ChartPriceOnDropped: result {result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartTimeOnDropped(object obj)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.ChartTimeOnDropped());
|
||||
AddLog($"ChartTimeOnDropped: result {result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartXOnDropped(object obj)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.ChartXOnDropped());
|
||||
AddLog($"ChartXOnDropped: result {result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartYOnDropped(object obj)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.ChartYOnDropped());
|
||||
AddLog($"ChartYOnDropped: result {result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartSetSymbolPeriod(object obj)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var symbol = ChartFunctionsSymbolValue;
|
||||
var result = await Execute(() => _mtApiClient.ChartSetSymbolPeriod(chartId, symbol, ENUM_TIMEFRAMES.PERIOD_M5));
|
||||
AddLog($"ChartSetSymbolPeriod: result {result} for chartid {chartId}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartScreenShot(object obj)
|
||||
{
|
||||
var chartId = ChartFunctionsChartIdValue;
|
||||
var filename = "ChartScreenShot_TestMtApi.gif";
|
||||
const int width = 800;
|
||||
const int height = 600;
|
||||
var result = await Execute(() => _mtApiClient.ChartScreenShot(chartId, filename, width, height));
|
||||
AddLog($"ChartScreenShot: result {result} for chartid {chartId}. Filename {filename}");
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void ExecuteUnlockTicks(object o)
|
||||
{
|
||||
_mtApiClient.UnlockTicks();
|
||||
}
|
||||
|
||||
private static void RunOnUiThread(Action action)
|
||||
{
|
||||
Application.Current?.Dispatcher.Invoke(action);
|
||||
@@ -956,27 +1593,29 @@ namespace MtApi5TestClient
|
||||
Application.Current?.Dispatcher.Invoke(action, args);
|
||||
}
|
||||
|
||||
private void mMtApiClient_QuoteUpdated(object sender, string symbol, double bid, double ask)
|
||||
private void mMtApiClient_QuoteUpdate(object sender, Mt5QuoteEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(symbol) == false)
|
||||
{
|
||||
if (_quotesMap.ContainsKey(symbol))
|
||||
{
|
||||
var qvm = _quotesMap[symbol];
|
||||
qvm.Bid = bid;
|
||||
qvm.Ask = ask;
|
||||
}
|
||||
var q = e.Quote;
|
||||
|
||||
if (string.Equals(symbol, TradeRequest.Symbol))
|
||||
Console.WriteLine(@"Quote: Symbol = {0}, Bid = {1}, Ask = {2}, Volume = {3}, Time = {4}, Last = {5}"
|
||||
, q.Instrument, q.Bid, q.Ask, q.Volume, q.Time, q.Last);
|
||||
|
||||
if (_quotesMap.ContainsKey(e.Quote.ExpertHandle))
|
||||
{
|
||||
var qvm = _quotesMap[e.Quote.ExpertHandle];
|
||||
qvm.Bid = e.Quote.Bid;
|
||||
qvm.Ask = e.Quote.Ask;
|
||||
}
|
||||
|
||||
if (string.Equals(e.Quote.Instrument, TradeRequest.Symbol))
|
||||
{
|
||||
if (TradeRequest.Type == ENUM_ORDER_TYPE.ORDER_TYPE_BUY)
|
||||
{
|
||||
if (TradeRequest.Type == ENUM_ORDER_TYPE.ORDER_TYPE_BUY)
|
||||
{
|
||||
TradeRequest.Price = ask;
|
||||
}
|
||||
else if (TradeRequest.Type == ENUM_ORDER_TYPE.ORDER_TYPE_SELL)
|
||||
{
|
||||
TradeRequest.Price = bid;
|
||||
}
|
||||
TradeRequest.Price = e.Quote.Ask;
|
||||
}
|
||||
else if (TradeRequest.Type == ENUM_ORDER_TYPE.ORDER_TYPE_SELL)
|
||||
{
|
||||
TradeRequest.Price = e.Quote.Bid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1020,44 +1659,46 @@ namespace MtApi5TestClient
|
||||
AddLog($"OnBookEvent: ExpertHandle = {e.ExpertHandle}, Symbol = {e.Symbol}");
|
||||
}
|
||||
|
||||
private void _mtApiClient_OnLastTimeBar(object sender, Mt5TimeBarArgs e)
|
||||
{
|
||||
AddLog($"OnBookEvent: ExpertHandle = {e.ExpertHandle}, Symbol = {e.Symbol}, open = {e.Rates.open}, close = {e.Rates.close}, time = {e.Rates.time}, high = {e.Rates.high}, low = {e.Rates.low}");
|
||||
}
|
||||
|
||||
private void _mtApiClient_OnLockTicks(object sender, Mt5LockTicksEventArgs e)
|
||||
{
|
||||
AddLog($"OnLockTicksEvent: Symbol = {e.Symbol}");
|
||||
}
|
||||
|
||||
private void AddQuote(Mt5Quote quote)
|
||||
{
|
||||
if (quote == null)
|
||||
if (_quotesMap.ContainsKey(quote.ExpertHandle))
|
||||
{
|
||||
AddLog($"AddQuote: Quote {quote.Instrument} with handle {quote.ExpertHandle} is present list. Skipped!");
|
||||
return;
|
||||
|
||||
QuoteViewModel qvm;
|
||||
|
||||
if (_quotesMap.ContainsKey(quote.Instrument) == false)
|
||||
{
|
||||
qvm = new QuoteViewModel(quote.Instrument);
|
||||
_quotesMap[quote.Instrument] = qvm;
|
||||
Quotes.Add(qvm);
|
||||
}
|
||||
else
|
||||
{
|
||||
qvm = _quotesMap[quote.Instrument];
|
||||
}
|
||||
|
||||
qvm.FeedCount++;
|
||||
qvm.Bid = quote.Bid;
|
||||
qvm.Ask = quote.Ask;
|
||||
var qvm = new QuoteViewModel(quote.Instrument)
|
||||
{
|
||||
ExpertHandle = quote.ExpertHandle,
|
||||
Bid = quote.Bid,
|
||||
Ask = quote.Ask
|
||||
};
|
||||
|
||||
_quotesMap[quote.ExpertHandle] = qvm;
|
||||
Quotes.Add(qvm);
|
||||
}
|
||||
|
||||
private void RemoveQuote(Mt5Quote quote)
|
||||
{
|
||||
if (quote == null) return;
|
||||
|
||||
if (_quotesMap.ContainsKey(quote.Instrument))
|
||||
if (_quotesMap.ContainsKey(quote.ExpertHandle) == false)
|
||||
{
|
||||
var qvm = _quotesMap[quote.Instrument];
|
||||
qvm.FeedCount--;
|
||||
|
||||
if (qvm.FeedCount <= 0)
|
||||
{
|
||||
_quotesMap.Remove(quote.Instrument);
|
||||
Quotes.Remove(qvm);
|
||||
}
|
||||
AddLog($"RemoveQuote: Quote {quote.Instrument} with handle {quote.ExpertHandle} is NOT present list. Skipped!");
|
||||
return;
|
||||
}
|
||||
|
||||
var qvm = _quotesMap[quote.ExpertHandle];
|
||||
_quotesMap.Remove(quote.ExpertHandle);
|
||||
Quotes.Remove(qvm);
|
||||
}
|
||||
|
||||
private void OnConnected()
|
||||
@@ -1108,6 +1749,7 @@ namespace MtApi5TestClient
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void AddLog(string msg)
|
||||
{
|
||||
RunOnUiThread(() =>
|
||||
@@ -1130,7 +1772,7 @@ namespace MtApi5TestClient
|
||||
#region Private Fields
|
||||
private readonly MtApi5Client _mtApiClient;
|
||||
|
||||
private readonly Dictionary<string, QuoteViewModel> _quotesMap;
|
||||
private readonly Dictionary<int, QuoteViewModel> _quotesMap = new Dictionary<int, QuoteViewModel>();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Executable → Regular
+1390
-54
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user