Compare commits

...

28 Commits

Author SHA1 Message Date
vdemydiuk cbe75cfbf6 Issue #83: Added command button HistoryDealMethods to check functions related to the issue 2018-02-08 18:04:15 +02:00
vdemydiuk 9581431a9f Issue #84: Fixed bug in function HistoryOrderGetInteger, there was wrong return value type 2018-02-04 14:39:09 +02:00
vdemydiuk acf0c12531 MT5: started version 1.0.15 2018-02-04 14:02:41 +02:00
DW 1eccda9b2c Version MtApi4 1.0.39 2018-01-16 16:11:33 +02:00
DW fd4aac7c32 Issie #73: added wrapped function getBooleanValueW into MtApi.mq4. Issue #76: added precompiled value __DEBUG_LOG__ into MtApi.mq4 to disable logging in release verion 2018-01-16 16:06:21 +02:00
DW 36c90c8481 Updated test application (MT5): added test functions HistoryDealGetDouble, HistoryDealGetInteger, HistoryDealGetString 2018-01-11 15:28:57 +02:00
DW fefa451371 Issue #39: Added indicator functions on MQL side (MtApi MT5) 2018-01-10 19:13:31 +02:00
DW 1c57f88cb1 Issue #72: Fixed bug with serialization of parameters in functions HistoryDealGetInteger, HistoryDealGetString, HistoryDealGetDouble 2017-11-27 18:16:35 +02:00
DW 08ba45c65f Issue #39: Added indicator functions on C# side (MtApi MT5) 2017-11-27 18:09:54 +02:00
DW b8314e9ed7 MtApi5: add waiting incoming connection on MT5 side in backtesting mode 2017-11-15 18:16:23 +02:00
DW 9587b10c8c MtApi5 version 1.0.14 2017-11-15 18:15:34 +02:00
DW b838084ba2 Issue #14: Updated test application for using function PositionOpen with MqlTradeResult 2017-09-29 19:05:06 +03:00
DW cd24891022 Issue #14: Added function PositionOpen which returns MqlTradeResult 2017-09-29 18:27:36 +03:00
DW add69a4c03 Issue #41: Complete object functions on MQL side 2017-09-29 17:39:18 +03:00
DW 5a3407e47c Issue #41: Refactored MtApi5.mq5 - removed unnecessary variables 2017-09-29 15:48:46 +03:00
DW ce8cfbbb70 Issue #41: Refactored MtApi5.mq5 2017-09-29 15:34:35 +03:00
DW 8470bbd5cc Issue #41: Complete object functions in client side (MT5) 2017-09-27 18:36:26 +03:00
DW 5c7ae748a5 Issue #41: Added Object Properties enums: ENUM_OBJECT_PROPERTY_INTEGER, ENUM_OBJECT_PROPERTY_STRING, ENUM_BORDER_TYPE, ENUM_ALIGN_MODE 2017-09-27 17:45:09 +03:00
DW 7abb4d3b5e Issue #41: Partialy implemented object functions on client side 2017-09-27 15:38:54 +03:00
DW 486c42685a Issue #41: Added Object Types enum 2017-09-26 18:37:50 +03:00
DW f41ab37b6f Set version 1.0.13 of MtApi (MT5) 2017-09-26 17:27:06 +03:00
Vyacheslav Demidyuk 9e129fb6e2 Merge pull request #64 from Tr4Dr/master
Fixes for the OrderSend function [MT5]
2017-09-25 12:41:35 +03:00
Tr4Dr f7b00a8d88 Added null check to convertSystemString [MT5]
Whithout this fix, the OrderSend method crashing if we doesn't set the "request.Comment" property.
2017-09-18 14:55:03 +02:00
Tr4Dr a7cb14de25 Updated MqlTradeRequest [MT5] 2017-09-18 02:05:22 +02:00
Tr4Dr f50925c8d3 Changed wcslen to wcsnlen [MT5]
Maximum character length set to 1000 based on preinit() MQL5 function. This value must be kept synchronized with MQL side.
2017-09-17 22:35:26 +02:00
Tr4Dr e29a11de68 Changed type of '\0' literal to wchar_t [MT5] 2017-09-17 22:19:09 +02:00
Tr4Dr 12141775f3 Fixed type casting to __int64 [MT5]
long long type should be an alternative.
2017-09-17 22:05:56 +02:00
Tr4Dr b6d24b8aa9 Merge pull request #2 from vdemydiuk/master
Update from original
2017-09-16 22:01:19 +02:00
22 changed files with 6498 additions and 1572 deletions
+12 -6
View File
@@ -51,9 +51,15 @@ public struct CMqlBookInfo
void convertSystemString(wchar_t* dest, String^ src)
{
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
memcpy(dest, wch, wcslen(wch) * sizeof(wchar_t));
dest[wcslen(wch)] = '\0';
if (src != nullptr) {
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
memcpy(dest, wch, wcsnlen(wch, 1000) * sizeof(wchar_t));
dest[wcsnlen(wch, 1000)] = L'\0';
}
else
{
dest[0] = L'\0';
}
}
#define _DLLAPI extern "C" __declspec(dllexport)
@@ -278,7 +284,7 @@ _DLLAPI int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* r
_DLLAPI int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res, wchar_t* err)
{
return Execute<int>([&expertHandle, &paramIndex, res]() {
*res = (unsigned long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = (unsigned __int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
return 1;
}, err, 0);
}
@@ -286,7 +292,7 @@ _DLLAPI int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __
_DLLAPI int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res, wchar_t* err)
{
return Execute<int>([&expertHandle, &paramIndex, res]() {
*res = (long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = (__int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
return 1;
}, err, 0);
}
@@ -306,4 +312,4 @@ _DLLAPI int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int
*res = (unsigned int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
return 1;
}, err, 0);
}
}
+7 -3
View File
@@ -9,9 +9,9 @@ namespace MTApiService
[DataMember]
public int Action { get; set; }
[DataMember]
public uint Magic { get; set; }
public ulong Magic { get; set; }
[DataMember]
public uint Order { get; set; }
public ulong Order { get; set; }
[DataMember]
public string Symbol { get; set; }
[DataMember]
@@ -25,7 +25,7 @@ namespace MTApiService
[DataMember]
public double Tp { get; set; }
[DataMember]
public uint Deviation { get; set; }
public ulong Deviation { get; set; }
[DataMember]
public int Type { get; set; }
[DataMember]
@@ -36,5 +36,9 @@ namespace MTApiService
public DateTime Expiration { get; set; }
[DataMember]
public string Comment { get; set; }
[DataMember]
public ulong Position { get; set; }
[DataMember]
public ulong PositionBy { get; set; }
}
}
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.38.0")]
[assembly: AssemblyFileVersion("1.0.38.0")]
[assembly: AssemblyVersion("1.0.39.0")]
[assembly: AssemblyFileVersion("1.0.39.0")]
+1 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MtApi5
namespace MtApi5
{
public class MqlTradeCheckResult
{
+7 -6
View File
@@ -1,8 +1,4 @@
using System;
using System.Linq;
using System.Text;
namespace MtApi5
namespace MtApi5
{
public class MqlTradeResult
{
@@ -27,6 +23,11 @@ namespace MtApi5
public double Bid { get; private set; } // Current Bid price
public double Ask { get; private set; } // Current Ask price
public string Comment { get; private set; } // Broker comment to operation (by default it is filled by the operation description)
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch
public override string ToString()
{
return $"Retcode={Retcode}; Deal={Deal}; Order={Order}; Volume={Volume}; Price={Price}; Bid={Bid}; Ask={Ask}; Comment={Comment}; Request_id={Request_id}";
}
}
}
+62 -7
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MtApi5
namespace MtApi5
{
internal enum Mt5CommandType
{
@@ -105,6 +100,7 @@ namespace MtApi5
//CTrade
PositionClose = 64,
PositionOpen = 65,
PositionOpenWithResult = 1065,
//Backtesting
BacktestingReady = 66,
@@ -115,6 +111,65 @@ namespace MtApi5
//Requests
MtRequest = 155,
PositionSelectByTicket = 69
PositionSelectByTicket = 69,
ObjectCreate = 70,
ObjectName = 71,
ObjectDelete = 72,
ObjectsDeleteAll = 73,
ObjectFind = 74,
ObjectGetTimeByValue = 75,
ObjectGetValueByTime = 76,
ObjectMove = 77,
ObjectsTotal = 78,
ObjectGetDouble = 79,
ObjectGetInteger = 80,
ObjectGetString = 81,
ObjectSetDouble = 82,
ObjectSetInteger = 83,
ObjectSetString = 84,
//TextSetFont = 85,
//TextOut = 86,
//TextGetSize = 87,
iAC = 88,
iAD = 89,
iADX = 90,
iADXWilder = 91,
iAlligator = 92,
iAMA = 93,
iAO = 94,
iATR = 95,
iBearsPower = 96,
iBands = 97,
iBullsPower = 98,
iCCI = 99,
iChaikin = 100,
//iCustom = 101,
iDEMA = 102,
iDeMarker = 103,
iEnvelopes = 104,
iForce = 105,
iFractals = 106,
iFrAMA = 107,
iGator = 108,
iIchimoku = 109,
iBWMFI = 110,
iMomentum = 111,
iMFI = 112,
iMA = 113,
iOsMA = 114,
iMACD = 115,
iOBV = 116,
iSAR = 117,
iRSI = 118,
iRVI = 119,
iStdDev = 120,
iStochastic = 121,
iTEMA = 122,
iTriX = 123,
iWPR = 124,
iVIDyA = 125,
iVolumes = 126
}
}
+177 -1
View File
@@ -606,4 +606,180 @@
#endregion //Trade Orders in Depth Of Market
}
#region Object Types
public enum ENUM_OBJECT
{
OBJ_VLINE = 0, // Vertical Line
OBJ_HLINE = 1, // Horizontal Line
OBJ_TREND = 2, // Trend Line
OBJ_TRENDBYANGLE = 3, // Trend Line By Angle
OBJ_CYCLES = 4, // Cycle Lines
OBJ_ARROWED_LINE = 108, // Arrowed Line
OBJ_CHANNEL = 5, // Equidistant Channel
OBJ_STDDEVCHANNEL = 6, // Standard Deviation Channel
OBJ_REGRESSION = 7, // Linear Regression Channel
OBJ_PITCHFORK = 8, // Andrews’ Pitchfork
OBJ_GANNLINE = 9, // Gann Line
OBJ_GANNFAN = 10, // Gann Fan
OBJ_GANNGRID = 11, // Gann Grid
OBJ_FIBO = 12, // Fibonacci Retracement
OBJ_FIBOTIMES = 13, // Fibonacci Time Zones
OBJ_FIBOFAN = 14, // Fibonacci Fan
OBJ_FIBOARC = 15, // Fibonacci Arcs
OBJ_FIBOCHANNEL = 16, // Fibonacci Channel
OBJ_EXPANSION = 17, // Fibonacci Expansion
OBJ_ELLIOTWAVE5 = 18, // Elliott Motive Wave
OBJ_ELLIOTWAVE3 = 19, // Elliott Correction Wave
OBJ_RECTANGLE = 20, // Rectangle
OBJ_TRIANGLE = 21, // Triangle
OBJ_ELLIPSE = 22, // Ellipse
OBJ_ARROW_THUMB_UP = 23, // Thumbs Up
OBJ_ARROW_THUMB_DOWN = 24, // Thumbs Down
OBJ_ARROW_UP = 25, // Arrow Up
OBJ_ARROW_DOWN = 26, // Arrow Down
OBJ_ARROW_STOP = 27, // Stop Sign
OBJ_ARROW_CHECK = 28, // Check Sign
OBJ_ARROW_LEFT_PRICE = 29, // Left Price Label
OBJ_ARROW_RIGHT_PRICE = 30, // Right Price Label
OBJ_ARROW_BUY = 31, // Buy Sign
OBJ_ARROW_SELL = 32, // Sell Sign
OBJ_ARROW = 100, // Arrow
OBJ_TEXT = 101, // Text
OBJ_LABEL = 102, // Label
OBJ_BUTTON = 103, // Button
OBJ_CHART = 104, // Chart
OBJ_BITMAP = 105, // Bitmap
OBJ_BITMAP_LABEL = 106, // Bitmap Label
OBJ_EDIT = 107, // Edit
OBJ_EVENT = 109, // The "Event" object corresponding to an event in the economic calendar
OBJ_RECTANGLE_LABEL = 110 // The "Rectangle label" object for creating and designing the custom graphical interface.
}
#endregion // Object Types
#region Object Properties
public enum ENUM_OBJECT_PROPERTY_DOUBLE
{
OBJPROP_PRICE = 9, // Price coordinate
OBJPROP_LEVELVALUE = 204, // Level value
OBJPROP_SCALE = 1006, // Scale (properties of Gann objects and Fibonacci Arcs)
OBJPROP_ANGLE = 1007, // Angle. For the objects with no angle specified, created from a program, the value is equal to EMPTY_VALUE
OBJPROP_DEVIATION = 1010 // Deviation for the Standard Deviation Channel
}
public enum ENUM_OBJECT_PROPERTY_INTEGER
{
OBJPROP_COLOR = 0, // Color
OBJPROP_STYLE = 1, // Style
OBJPROP_WIDTH = 2, // Line thickness
OBJPROP_BACK = 3, // Object in the background
OBJPROP_ZORDER = 207, // Priority of a graphical object for receiving events of clicking on a chart (CHARTEVENT_CLICK). The default zero value is set when creating an object; the priority can be increased if necessary. When objects are placed one atop another, only one of them with the highest priority will receive the CHARTEVENT_CLICK event.
OBJPROP_FILL = 1031, // Fill an object with color (for OBJ_RECTANGLE, OBJ_TRIANGLE, OBJ_ELLIPSE, OBJ_CHANNEL, OBJ_STDDEVCHANNEL, OBJ_REGRESSION)
OBJPROP_HIDDEN = 208, // Prohibit showing of the name of a graphical object in the list of objects from the terminal menu "Charts" - "Objects" - "List of objects". The true value allows to hide an object from the list. By default, true is set to the objects that display calendar events, trading history and to the objects created from MQL5 programs. To see such graphical objects and access their properties, click on the "All" button in the "List of objects" window.
OBJPROP_SELECTED = 4, // Object is selected
OBJPROP_READONLY = 1028, // Ability to edit text in the Edit object
OBJPROP_TYPE = 7, // Object type
OBJPROP_TIME = 8, // Time coordinate
OBJPROP_SELECTABLE = 10, // Object availability
OBJPROP_CREATETIME = 11, // Time of object creation
OBJPROP_LEVELS = 200, // Number of levels
OBJPROP_LEVELCOLOR = 201, // Color of the line-level
OBJPROP_LEVELSTYLE = 202, // Style of the line-level
OBJPROP_LEVELWIDTH = 203, // Thickness of the line-level
OBJPROP_ALIGN = 1036, // Horizontal text alignment in the "Edit" object (OBJ_EDIT)
OBJPROP_FONTSIZE = 1002, // Font size
OBJPROP_RAY_LEFT = 1003, // Ray goes to the left
OBJPROP_RAY_RIGHT = 1004, // Ray goes to the right
OBJPROP_RAY = 1032, // A vertical line goes through all the windows of a chart
OBJPROP_ELLIPSE = 1005, // Showing the full ellipse of the Fibonacci Arc object (OBJ_FIBOARC)
OBJPROP_ARROWCODE = 1008, // Arrow code for the Arrow object
OBJPROP_TIMEFRAMES = 12, // Visibility of an object at timeframes
OBJPROP_ANCHOR = 1011, // Location of the anchor point of a graphical object
OBJPROP_XDISTANCE = 1012, // The distance in pixels along the X axis from the binding corner
OBJPROP_YDISTANCE = 1013, // The distance in pixels along the Y axis from the binding corner
OBJPROP_DIRECTION = 1014, // Trend of the Gann object
OBJPROP_DEGREE = 1015, // Level of the Elliott Wave Marking
OBJPROP_DRAWLINES = 1016, // Displaying lines for marking the Elliott Wave
OBJPROP_STATE = 1018, // Button state (pressed / depressed)
OBJPROP_CHART_ID = 1030, // ID of the "Chart" object (OBJ_CHART). It allows working with the properties of this object like with a normal chart using the functions described in Chart Operations, but there some exceptions.
OBJPROP_XSIZE = 1019, // The object's width along the X axis in pixels. Specified for OBJ_LABEL (read only), OBJ_BUTTON, OBJ_CHART, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL objects.
OBJPROP_YSIZE = 1020, // The object's height along the Y axis in pixels. Specified for OBJ_LABEL (read only), OBJ_BUTTON, OBJ_CHART, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL objects.
OBJPROP_XOFFSET = 1033, // The X coordinate of the upper left corner of the rectangular visible area in the graphical objects "Bitmap Label" and "Bitmap" (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image.
OBJPROP_YOFFSET = 1034, // The Y coordinate of the upper left corner of the rectangular visible area in the graphical objects "Bitmap Label" and "Bitmap" (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image.
OBJPROP_PERIOD = 1022, // Timeframe for the Chart object
OBJPROP_DATE_SCALE = 1023, // Displaying the time scale for the Chart object
OBJPROP_PRICE_SCALE = 1024, // Displaying the price scale for the Chart object
OBJPROP_CHART_SCALE = 1027, // The scale for the Chart object
OBJPROP_BGCOLOR = 1025, // The background color for OBJ_EDIT, OBJ_BUTTON, OBJ_RECTANGLE_LABEL
OBJPROP_CORNER = 1026, // The corner of the chart to link a graphical object
OBJPROP_BORDER_TYPE = 1029, // Border type for the "Rectangle label" object
OBJPROP_BORDER_COLOR = 1035 // Border color for the OBJ_EDIT and OBJ_BUTTON objects
}
public enum ENUM_OBJECT_PROPERTY_STRING
{
OBJPROP_NAME = 5, // Object name
OBJPROP_TEXT = 6, // Description of the object (the text contained in the object)
OBJPROP_TOOLTIP = 206, // The text of a tooltip. If the property is not set, then the tooltip generated automatically by the terminal is shown. A tooltip can be disabled by setting the "\n" (line feed) value to it
OBJPROP_LEVELTEXT = 205, // Level description
OBJPROP_FONT = 1001, // Font
OBJPROP_BMPFILE = 1017, // The name of BMP-file for Bitmap Label.
OBJPROP_SYMBOL = 1021 // Symbol for the Chart object
}
public enum ENUM_BORDER_TYPE
{
BORDER_FLAT = 0, // Flat form
BORDER_RAISED = 1, // Prominent form
BORDER_SUNKEN = 2 // Concave form
}
public enum ENUM_ALIGN_MODE
{
ALIGN_LEFT = 1, // Left alignment
ALIGN_CENTER = 2, // Centered (only for the Edit object)
ALIGN_RIGHT = 0, // Right alignment
}
#endregion //Object Properties
#region Price Constants
public enum ENUM_APPLIED_PRICE
{
PRICE_CLOSE = 1, //Close price
PRICE_OPEN = 2, //Open price
PRICE_HIGH = 3, //The maximum price for the period
PRICE_LOW = 4, //The minimum price for the period
PRICE_MEDIAN = 5, //Median price, (high + low)/2
PRICE_TYPICAL = 6, //Typical price, (high + low + close)/3
PRICE_WEIGHTED = 7 //Average price, (high + low + close + close)/4
}
public enum ENUM_APPLIED_VOLUME
{
VOLUME_TICK = 0, //Tick volume
VOLUME_REAL = 1 //Trade volume
}
public enum ENUM_STO_PRICE
{
STO_LOWHIGH = 0, //Calculation is based on Low/High prices
STO_CLOSECLOSE = 1 //Calculation is based on Close/Close prices
}
#endregion //Price Constants
#region Smoothing Methods
public enum ENUM_MA_METHOD
{
MODE_SMA = 0, //Simple averaging
MODE_EMA = 1, //Exponential averaging
MODE_SMMA = 2, //Smoothed averaging
MODE_LWMA = 3 //Linear-weighted averaging
}
#endregion //Smoothing Methods
}
+2
View File
@@ -67,9 +67,11 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Mt5Quote.cs" />
<Compile Include="Requests\CopyTicksRequest.cs" />
<Compile Include="Requests\ICustomRequest.cs" />
<Compile Include="Requests\RequestBase.cs" />
<Compile Include="Requests\RequestType.cs" />
<Compile Include="Responses\CopyTicksResponse.cs" />
<Compile Include="Responses\ICustomResponse.cs" />
<Compile Include="Responses\ResponseBase.cs" />
</ItemGroup>
<ItemGroup>
+785 -7
View File
@@ -456,7 +456,7 @@ namespace MtApi5
///<param name="propertyId"> Identifier of a deal property.</param>
public double HistoryDealGetDouble(ulong ticketNumber, ENUM_DEAL_PROPERTY_DOUBLE propertyId)
{
var commandParameters = new ArrayList { ticketNumber, propertyId };
var commandParameters = new ArrayList { ticketNumber, (int)propertyId };
return SendCommand<double>(Mt5CommandType.HistoryDealGetDouble, commandParameters);
}
@@ -468,7 +468,7 @@ namespace MtApi5
///<param name="propertyId"> Identifier of a deal property.</param>
public long HistoryDealGetInteger(ulong ticketNumber, ENUM_DEAL_PROPERTY_INTEGER propertyId)
{
var commandParameters = new ArrayList { ticketNumber, propertyId };
var commandParameters = new ArrayList { ticketNumber, (int)propertyId };
return SendCommand<long>(Mt5CommandType.HistoryDealGetInteger, commandParameters);
}
@@ -480,7 +480,7 @@ namespace MtApi5
///<param name="propertyId"> Identifier of a deal property.</param>
public string HistoryDealGetString(ulong ticketNumber, ENUM_DEAL_PROPERTY_STRING propertyId)
{
var commandParameters = new ArrayList { ticketNumber, propertyId };
var commandParameters = new ArrayList { ticketNumber, (int)propertyId };
return SendCommand<string>(Mt5CommandType.HistoryDealGetString, commandParameters);
}
@@ -522,6 +522,25 @@ namespace MtApi5
return SendCommand<bool>(Mt5CommandType.PositionOpen, commandParameters);
}
/// <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="comment">comment</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)
{
var commandParameters = new ArrayList { symbol, (int)orderType, volume, price, sl, tp, comment };
var strResult = SendCommand<string>(Mt5CommandType.PositionOpenWithResult, commandParameters);
return strResult.ParseResult(ParamSeparator, out result);
}
#endregion
#region Account Information functions
@@ -1419,9 +1438,769 @@ namespace MtApi5
return SendCommand<bool>(Mt5CommandType.Print, commandParameters);
}
#endregion
#endregion // Common Functions
#endregion
#region Object Functions
///<summary>
///The function creates an object with the specified name, type, and the initial coordinates in the specified chart subwindow.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object. The name must be unique within a chart, including its subwindows.</param>
///<param name="type">Object type. The value can be one of the values of the ENUM_OBJECT enumeration.</param>
///<param name="nwin">Number of the chart subwindow. 0 means the main chart window. The specified subwindow must exist, otherwise the function returns false.</param>
///<param name="time">The time coordinate of the first anchor.</param>
///<param name="price">The price coordinate of the first anchor point.</param>
public bool ObjectCreate(long chartId, string name, ENUM_OBJECT type, int nwin, DateTime time, double price)
{
var commandParameters = new ArrayList { chartId, name, (int)type, nwin, Mt5TimeConverter.ConvertToMtTime(time), price };
return SendCommand<bool>(Mt5CommandType.ObjectCreate, commandParameters);
}
///<summary>
///The function returns the name of the corresponding object in the specified chart, in the specified subwindow, of the specified type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="pos">Ordinal number of the object according to the specified filter by the number and type of the subwindow.</param>
///<param name="subWindow">umber of the chart subwindow. 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.</param>
///<param name="type">Type of the object. The value can be one of the values of the ENUM_OBJECT enumeration. -1 means all types.</param>
public string ObjectName(long chartId, int pos, int subWindow = -1, int type = -1)
{
var commandParameters = new ArrayList { chartId, pos, subWindow, type };
return SendCommand<string>(Mt5CommandType.ObjectName, commandParameters);
}
///<summary>
///The function removes the object with the specified name from the specified chart.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of object to be deleted.</param>
public bool ObjectDelete(long chartId, string name)
{
var commandParameters = new ArrayList { chartId, name };
return SendCommand<bool>(Mt5CommandType.ObjectDelete, commandParameters);
}
///<summary>
///The function removes the object with the specified name from the specified chart.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="subWindow">Number of the chart subwindow. 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.</param>
///<param name="type">Type of the object. The value can be one of the values of the ENUM_OBJECT enumeration. -1 means all types.</param>
public int ObjectsDeleteAll(long chartId, int subWindow = -1, int type = -1)
{
var commandParameters = new ArrayList { chartId, subWindow, type };
return SendCommand<int>(Mt5CommandType.ObjectsDeleteAll, commandParameters);
}
///<summary>
///The function searches for an object with the specified name in the chart with the specified ID.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">The name of the searched object.</param>
public int ObjectFind(long chartId, string name)
{
var commandParameters = new ArrayList { chartId, name };
return SendCommand<int>(Mt5CommandType.ObjectFind, commandParameters);
}
///<summary>
///The function returns the time value for the specified price value of the specified object.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="value">Price value.</param>
///<param name="lineId">Line identifier.</param>
public DateTime ObjectGetTimeByValue(long chartId, string name, double value, int lineId)
{
var commandParameters = new ArrayList { chartId, name, value, lineId };
var res = SendCommand<int>(Mt5CommandType.ObjectGetTimeByValue, commandParameters);
return Mt5TimeConverter.ConvertFromMtTime(res);
}
///<summary>
///The function returns the price value for the specified time value of the specified object.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="time">Time value.</param>
///<param name="lineId">Line identifier.</param>
public double ObjectGetValueByTime(long chartId, string name, DateTime time, int lineId)
{
var commandParameters = new ArrayList { chartId, name, Mt5TimeConverter.ConvertToMtTime(time), lineId };
return SendCommand<double>(Mt5CommandType.ObjectGetValueByTime, commandParameters);
}
///<summary>
///The function changes coordinates of the specified anchor point of the object.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="pointIndex">Index of the anchor point. The number of anchor points depends on the type of object.</param>
///<param name="time">Time coordinate of the selected anchor point.</param>
///<param name="price">Price coordinate of the selected anchor point.</param>
public bool ObjectMove(long chartId, string name, int pointIndex, DateTime time, double price)
{
var commandParameters = new ArrayList { chartId, name, pointIndex, Mt5TimeConverter.ConvertToMtTime(time), price };
return SendCommand<bool>(Mt5CommandType.ObjectMove, commandParameters);
}
///<summary>
///The function returns the number of objects in the specified chart, specified subwindow, of the specified type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="subWindow">Number of the chart subwindow. 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.</param>
///<param name="type">Type of the object. The value can be one of the values of the ENUM_OBJECT enumeration. -1 means all types.</param>
public int ObjectsTotal(long chartId, int subWindow = -1, int type = -1)
{
var commandParameters = new ArrayList { chartId, subWindow, type };
return SendCommand<int>(Mt5CommandType.ObjectsTotal, commandParameters);
}
///<summary>
///The function sets the value of the corresponding object property. The object property must be of the double type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_DOUBLE enumeration.</param>
///<param name="propValue">The value of the property.</param>
public bool ObjectSetDouble(long chartId, string name, ENUM_OBJECT_PROPERTY_DOUBLE propId, double propValue)
{
var commandParameters = new ArrayList { chartId, name, (int)propId, propValue };
return SendCommand<bool>(Mt5CommandType.ObjectSetDouble, commandParameters);
}
///<summary>
///The function sets the value of the corresponding object property. The object property must be of the datetime, int, color, bool or char type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_INTEGER enumeration.</param>
///<param name="propValue">The value of the property.</param>
public bool ObjectSetInteger(long chartId, string name, ENUM_OBJECT_PROPERTY_INTEGER propId, long propValue)
{
var commandParameters = new ArrayList { chartId, name, (int)propId, propValue };
return SendCommand<bool>(Mt5CommandType.ObjectSetInteger, commandParameters);
}
///<summary>
///The function sets the value of the corresponding object property. The object property must be of the string type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_STRING enumeration.</param>
///<param name="propValue">The value of the property.</param>
public bool ObjectSetString(long chartId, string name, ENUM_OBJECT_PROPERTY_STRING propId, string propValue)
{
var commandParameters = new ArrayList { chartId, name, (int)propId, propValue };
return SendCommand<bool>(Mt5CommandType.ObjectSetString, commandParameters);
}
///<summary>
///The function returns the value of the corresponding object property. The object property must be of the double type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_DOUBLE enumeration.</param>
public double ObjectGetDouble(long chartId, string name, ENUM_OBJECT_PROPERTY_DOUBLE propId)
{
var commandParameters = new ArrayList { chartId, name, (int)propId };
return SendCommand<double>(Mt5CommandType.ObjectGetDouble, commandParameters);
}
///<summary>
///he function returns the value of the corresponding object property. The object property must be of the datetime, int, color, bool or char type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_INTEGER enumeration.</param>
public long ObjectGetInteger(long chartId, string name, ENUM_OBJECT_PROPERTY_INTEGER propId)
{
var commandParameters = new ArrayList { chartId, name, (int)propId };
return SendCommand<long>(Mt5CommandType.ObjectGetInteger, commandParameters);
}
///<summary>
///The function returns the value of the corresponding object property. The object property must be of the string type.
///</summary>
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
///<param name="name">Name of the object.</param>
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_STRING enumeration.</param>
public string ObjectGetString(long chartId, string name, ENUM_OBJECT_PROPERTY_STRING propId)
{
var commandParameters = new ArrayList { chartId, name, (int)propId };
return SendCommand<string>(Mt5CommandType.ObjectGetString, commandParameters);
}
#endregion //Object Functions
#region Technical Indicators
#endregion //Technical Indicators
///<summary>
///The function creates Accelerator Oscillator in a global cache of the client terminal and returns its handle.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
public int iAC(string symbol, ENUM_TIMEFRAMES period)
{
var commandParameters = new ArrayList { symbol, (int)period };
return SendCommand<int>(Mt5CommandType.iAC, commandParameters);
}
///<summary>
///The function returns the handle of the Accumulation/Distribution indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="appliedVolume">The volume used. Can be any of ENUM_APPLIED_VOLUME values.</param>
public int iAD(string symbol, ENUM_TIMEFRAMES period, ENUM_APPLIED_VOLUME appliedVolume)
{
var commandParameters = new ArrayList { symbol, (int)period, (int)appliedVolume };
return SendCommand<int>(Mt5CommandType.iAD, commandParameters);
}
///<summary>
///The function returns the handle of the Average Directional Movement Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="adxPeriod">Period to calculate the index.</param>
public int iADX(string symbol, ENUM_TIMEFRAMES period, int adxPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, adxPeriod };
return SendCommand<int>(Mt5CommandType.iADX, commandParameters);
}
///<summary>
///The function returns the handle of Average Directional Movement Index by Welles Wilder.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="adxPeriod">Period to calculate the index.</param>
public int iADXWilder(string symbol, ENUM_TIMEFRAMES period, int adxPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, adxPeriod };
return SendCommand<int>(Mt5CommandType.iADXWilder, commandParameters);
}
///<summary>
///The function returns the handle of the Alligator indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="jawPeriod">Averaging period for the blue line (Alligator's Jaw).</param>
///<param name="jawShift">The shift of the blue line relative to the price chart.</param>
///<param name="teethPeriod">Averaging period for the red line (Alligator's Teeth).</param>
///<param name="teethShift">The shift of the red line relative to the price chart.</param>
///<param name="lipsPeriod">Averaging period for the green line (Alligator's lips).</param>
///<param name="lipsShift">The shift of the green line relative to the price chart.</param>
///<param name="maMethod">The method of averaging. Can be any of the ENUM_MA_METHOD values.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iAlligator(string symbol, ENUM_TIMEFRAMES period, int jawPeriod, int jawShift, int teethPeriod,
int teethShift, int lipsPeriod, int lipsShift, ENUM_MA_METHOD maMethod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, jawPeriod, jawShift, teethPeriod, teethShift, lipsPeriod, lipsShift, (int)maMethod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iAlligator, commandParameters);
}
///<summary>
///The function returns the handle of the Adaptive Moving Average indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="amaPeriod">The calculation period, on which the efficiency coefficient is calculated.</param>
///<param name="fastMaPeriod">Fast period for the smoothing coefficient calculation for a rapid market.</param>
///<param name="slowMaPeriod">Slow period for the smoothing coefficient calculation in the absence of trend.</param>
///<param name="amaShift">Shift of the indicator relative to the price chart.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iAMA(string symbol, ENUM_TIMEFRAMES period, int amaPeriod, int fastMaPeriod, int slowMaPeriod, int amaShift, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, amaPeriod, fastMaPeriod, slowMaPeriod, amaShift, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iAMA, commandParameters);
}
///<summary>
///The function returns the handle of the Awesome Oscillator indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
public int iAO(string symbol, ENUM_TIMEFRAMES period)
{
var commandParameters = new ArrayList { symbol, (int)period };
return SendCommand<int>(Mt5CommandType.iAO, commandParameters);
}
///<summary>
///The function returns the handle of the Average True Range indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">The value of the averaging period for the indicator calculation.</param>
public int iATR(string symbol, ENUM_TIMEFRAMES period, int maPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod };
return SendCommand<int>(Mt5CommandType.iATR, commandParameters);
}
///<summary>
///The function returns the handle of the Bears Power indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">The value of the averaging period for the indicator calculation.</param>
public int iBearsPower(string symbol, ENUM_TIMEFRAMES period, int maPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod };
return SendCommand<int>(Mt5CommandType.iBearsPower, commandParameters);
}
///<summary>
///The function returns the handle of the Bollinger Bands® indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="bandsPeriod">The averaging period of the main line of the indicator.</param>
///<param name="bandsShift">The shift the indicator relative to the price chart.</param>
///<param name="deviation">Deviation from the main line.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iBands(string symbol, ENUM_TIMEFRAMES period, int bandsPeriod, int bandsShift, double deviation, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, bandsPeriod, bandsShift, deviation, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iBands, commandParameters);
}
///<summary>
///The function returns the handle of the Bulls Power indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">The averaging period for the indicator calculation.</param>
public int iBullsPower(string symbol, ENUM_TIMEFRAMES period, int maPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod };
return SendCommand<int>(Mt5CommandType.iBullsPower, commandParameters);
}
///<summary>
///The function returns the handle of the Commodity Channel Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">The averaging period for the indicator calculation.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iCCI(string symbol, ENUM_TIMEFRAMES period, int maPeriod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iCCI, commandParameters);
}
///<summary>
///The function returns the handle of the Bulls Power indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="fastMaPeriod">Fast averaging period for calculations.</param>
///<param name="slowMaPeriod">Slow averaging period for calculations.</param>
///<param name="maMethod">Smoothing type. Can be one of the averaging constants of ENUM_MA_METHOD.</param>
///<param name="appliedVolume">The volume used. Can be one of the constants of ENUM_APPLIED_VOLUME.</param>
public int iChaikin(string symbol, ENUM_TIMEFRAMES period, int fastMaPeriod, int slowMaPeriod, ENUM_MA_METHOD maMethod, ENUM_APPLIED_VOLUME appliedVolume)
{
var commandParameters = new ArrayList { symbol, (int)period, fastMaPeriod, slowMaPeriod, (int)maMethod, (int)appliedVolume };
return SendCommand<int>(Mt5CommandType.iChaikin, commandParameters);
}
///<summary>
///The function returns the handle of the Bulls Power indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period (bars count) for calculations.</param>
///<param name="maShift">Shift of the indicator relative to the price chart.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iDEMA(string symbol, ENUM_TIMEFRAMES period, int maPeriod, int maShift, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, maShift, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iDEMA, commandParameters);
}
///<summary>
///The function returns the handle of the DeMarker indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period (bars count) for calculations.</param>
public int iDeMarker(string symbol, ENUM_TIMEFRAMES period, int maPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod };
return SendCommand<int>(Mt5CommandType.iDeMarker, commandParameters);
}
///<summary>
///The function returns the handle of the Envelopes indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period for the main line.</param>
///<param name="maShift">The shift of the indicator relative to the price chart.</param>
///<param name="maMethod">Smoothing type. Can be one of the values of ENUM_MA_METHOD.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
///<param name="deviation">The deviation from the main line (in percents).</param>
public int iEnvelopes(string symbol, ENUM_TIMEFRAMES period, int maPeriod, int maShift, ENUM_MA_METHOD maMethod, ENUM_APPLIED_PRICE appliedPrice, double deviation)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, maShift, (int)maMethod, (int)appliedPrice, deviation };
return SendCommand<int>(Mt5CommandType.iEnvelopes, commandParameters);
}
///<summary>
///The function returns the handle of the Force Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period for the indicator calculations.</param>
///<param name="maMethod">Smoothing type. Can be one of the values of ENUM_MA_METHOD.</param>
///<param name="appliedVolume">The volume used. Can be one of the values of ENUM_APPLIED_VOLUME.</param>
public int iForce(string symbol, ENUM_TIMEFRAMES period, int maPeriod, ENUM_MA_METHOD maMethod, ENUM_APPLIED_VOLUME appliedVolume)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, (int)maMethod, (int)appliedVolume };
return SendCommand<int>(Mt5CommandType.iForce, commandParameters);
}
///<summary>
///The function returns the handle of the Force Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
public int iForce(string symbol, ENUM_TIMEFRAMES period)
{
var commandParameters = new ArrayList { symbol, (int)period };
return SendCommand<int>(Mt5CommandType.iForce, commandParameters);
}
///<summary>
///The function returns the handle of the Fractal Adaptive Moving Average indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Period (bars count) for the indicator calculations.</param>
///<param name="maShift">Shift of the indicator in the price chart.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iFrAMA(string symbol, ENUM_TIMEFRAMES period, int maPeriod, int maShift, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, maShift, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iFrAMA, commandParameters);
}
///<summary>
///The function returns the handle of the Gator indicator. The Oscillator shows the difference between the blue and red lines of Alligator (upper histogram) and difference between red and green lines (lower histogram).
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="jawPeriod">Averaging period for the blue line (Alligator's Jaw).</param>
///<param name="jawShift">The shift of the blue line relative to the price chart. It isn't directly connected with the visual shift of the indicator histogram.</param>
///<param name="teethPeriod">Averaging period for the red line (Alligator's Teeth).</param>
///<param name="teethShift">The shift of the red line relative to the price chart. It isn't directly connected with the visual shift of the indicator histogram.</param>
///<param name="lipsPeriod">Averaging period for the green line (Alligator's lips).</param>
///<param name="lipsShift">The shift of the green line relative to the price charts. It isn't directly connected with the visual shift of the indicator histogram.</param>
///<param name="maMethod">Smoothing type. Can be one of the values of ENUM_MA_METHOD.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iGator(string symbol, ENUM_TIMEFRAMES period, int jawPeriod, int jawShift, int teethPeriod,
int teethShift, int lipsPeriod, int lipsShift, ENUM_MA_METHOD maMethod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, jawPeriod, jawShift, teethPeriod, teethShift, lipsPeriod, lipsShift, (int)maMethod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iGator, commandParameters);
}
///<summary>
///The function returns the handle of the Ichimoku Kinko Hyo indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="tenkanSen">Averaging period for Tenkan Sen.</param>
///<param name="kijunSen">Averaging period for Kijun Sen.</param>
///<param name="senkouSpanB">Averaging period for Senkou Span B.</param>
public int iIchimoku(string symbol, ENUM_TIMEFRAMES period, int tenkanSen, int kijunSen, int senkouSpanB)
{
var commandParameters = new ArrayList { symbol, (int)period, tenkanSen, kijunSen, senkouSpanB };
return SendCommand<int>(Mt5CommandType.iIchimoku, commandParameters);
}
///<summary>
///The function returns the handle of the Market Facilitation Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="appliedVolume">The volume used. Can be one of the constants of ENUM_APPLIED_VOLUME.</param>
public int iBWMFI(string symbol, ENUM_TIMEFRAMES period, ENUM_APPLIED_VOLUME appliedVolume)
{
var commandParameters = new ArrayList { symbol, (int)period, (int)appliedVolume };
return SendCommand<int>(Mt5CommandType.iBWMFI, commandParameters);
}
///<summary>
///The function returns the handle of the Momentum indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="momPeriod">Averaging period (bars count) for the calculation of the price change.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iMomentum(string symbol, ENUM_TIMEFRAMES period, int momPeriod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, momPeriod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iMomentum, commandParameters);
}
///<summary>
///The function returns the handle of the Money Flow Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period (bars count) for the calculation.</param>
///<param name="appliedVolume">The volume used. Can be any of the ENUM_APPLIED_VOLUME values.</param>
public int iMFI(string symbol, ENUM_TIMEFRAMES period, int maPeriod, ENUM_APPLIED_VOLUME appliedVolume)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, (int)appliedVolume };
return SendCommand<int>(Mt5CommandType.iMFI, commandParameters);
}
///<summary>
///The function returns the handle of the Moving Average indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period for the calculation of the moving average.</param>
///<param name="maShift">Shift of the indicator relative to the price chart.</param>
///<param name="maMethod">Smoothing type. Can be one of the ENUM_MA_METHOD values.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iMA(string symbol, ENUM_TIMEFRAMES period, int maPeriod, int maShift, ENUM_MA_METHOD maMethod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, maShift, (int)maMethod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iMA, commandParameters);
}
///<summary>
///The function returns the handle of the Moving Average of Oscillator indicator. The OsMA oscillator shows the difference between values of MACD and its signal line.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="fastEmaPeriod">Period for Fast Moving Average calculation.</param>
///<param name="slowEmaPeriod">Period for Slow Moving Average calculation.</param>
///<param name="signalPeriod">Averaging period for signal line calculation.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iOsMA(string symbol, ENUM_TIMEFRAMES period, int fastEmaPeriod, int slowEmaPeriod, int signalPeriod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, fastEmaPeriod, slowEmaPeriod, signalPeriod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iOsMA, commandParameters);
}
///<summary>
///The function returns the handle of the Moving Averages Convergence/Divergence indicator. In systems where OsMA is called MACD Histogram, this indicator is shown as two lines. In the client terminal the Moving Averages Convergence/Divergence looks like a histogram.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="fastEmaPeriod">Period for Fast Moving Average calculation.</param>
///<param name="slowEmaPeriod">Period for Slow Moving Average calculation.</param>
///<param name="signalPeriod">Averaging period for signal line calculation.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iMACD(string symbol, ENUM_TIMEFRAMES period, int fastEmaPeriod, int slowEmaPeriod, int signalPeriod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, fastEmaPeriod, slowEmaPeriod, signalPeriod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iMACD, commandParameters);
}
///<summary>
///The function returns the handle of the On Balance Volume indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="appliedVolume">The volume used. Can be any of the ENUM_APPLIED_VOLUME values.</param>
public int iOBV(string symbol, ENUM_TIMEFRAMES period, ENUM_APPLIED_VOLUME appliedVolume)
{
var commandParameters = new ArrayList { symbol, (int)period, (int)appliedVolume };
return SendCommand<int>(Mt5CommandType.iOBV, commandParameters);
}
///<summary>
///The function returns the handle of the Parabolic Stop and Reverse system indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="step">The step of price increment, usually 0.02.</param>
///<param name="maximum">The maximum step, usually 0.2.</param>
public int iSAR(string symbol, ENUM_TIMEFRAMES period, double step, double maximum)
{
var commandParameters = new ArrayList { symbol, (int)period, step, maximum };
return SendCommand<int>(Mt5CommandType.iSAR, commandParameters);
}
///<summary>
///The function returns the handle of the Relative Strength Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period for the RSI calculation.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iRSI(string symbol, ENUM_TIMEFRAMES period, int maPeriod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iRSI, commandParameters);
}
///<summary>
///The function returns the handle of the Relative Vigor Index indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period for the RVI calculation.</param>
public int iRVI(string symbol, ENUM_TIMEFRAMES period, int maPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod };
return SendCommand<int>(Mt5CommandType.iRVI, commandParameters);
}
///<summary>
///The function returns the handle of the Standard Deviation indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period for the RVI calculation.</param>
///<param name="maShift">Shift of the indicator relative to the price chart.</param>
///<param name="maMethod">Type of averaging. Can be any of the ENUM_MA_METHOD values.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iStdDev(string symbol, ENUM_TIMEFRAMES period, int maPeriod, int maShift, ENUM_MA_METHOD maMethod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, maShift, (int)maMethod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iStdDev, commandParameters);
}
///<summary>
///The function returns the handle of the Stochastic Oscillator indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="Kperiod">Averaging period (bars count) for the %K line calculation.</param>
///<param name="Dperiod">Averaging period (bars count) for the %D line calculation.</param>
///<param name="slowing">Slowing value.</param>
///<param name="maMethod">Type of averaging. Can be any of the ENUM_MA_METHOD values.</param>
///<param name="priceField">Parameter of price selection for calculations. Can be one of the ENUM_STO_PRICE values.</param>
public int iStochastic(string symbol, ENUM_TIMEFRAMES period, int Kperiod, int Dperiod, int slowing, ENUM_MA_METHOD maMethod, ENUM_STO_PRICE priceField)
{
var commandParameters = new ArrayList { symbol, (int)period, Kperiod, Dperiod, slowing, (int)maMethod, (int)priceField };
return SendCommand<int>(Mt5CommandType.iStochastic, commandParameters);
}
///<summary>
///The function returns the handle of the Triple Exponential Moving Average indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period (bars count) for calculation.</param>
///<param name="maShift">Shift of indicator relative to the price chart.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iTEMA(string symbol, ENUM_TIMEFRAMES period, int maPeriod, int maShift, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, maShift, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iTEMA, commandParameters);
}
///<summary>
///The function returns the handle of the Triple Exponential Moving Averages Oscillator indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="maPeriod">Averaging period (bars count) for calculation.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iTriX(string symbol, ENUM_TIMEFRAMES period, int maPeriod, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, maPeriod, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iTriX, commandParameters);
}
///<summary>
///The function returns the handle of the Larry Williams' Percent Range indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="calcPeriod">Period (bars count) for the indicator calculation.</param>
public int iWPR(string symbol, ENUM_TIMEFRAMES period, int calcPeriod)
{
var commandParameters = new ArrayList { symbol, (int)period, calcPeriod };
return SendCommand<int>(Mt5CommandType.iWPR, commandParameters);
}
///<summary>
///The function returns the handle of the Variable Index Dynamic Average indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="cmoPeriod">Period (bars count) for the Chande Momentum Oscillator calculation.</param>
///<param name="emaPeriod">EMA period (bars count) for smoothing factor calculation.</param>
///<param name="maShift">Shift of the indicator relative to the price chart.</param>
///<param name="appliedPrice">The price used. Can be any of the price constants ENUM_APPLIED_PRICE or a handle of another indicator.</param>
public int iVIDyA(string symbol, ENUM_TIMEFRAMES period, int cmoPeriod, int emaPeriod, int maShift, ENUM_APPLIED_PRICE appliedPrice)
{
var commandParameters = new ArrayList { symbol, (int)period, cmoPeriod, emaPeriod, maShift, (int)appliedPrice };
return SendCommand<int>(Mt5CommandType.iVIDyA, commandParameters);
}
///<summary>
///The function returns the handle of the Volumes indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="appliedVolume">The volume used. Can be any of the ENUM_APPLIED_VOLUME values.</param>
public int iVolumes(string symbol, ENUM_TIMEFRAMES period, ENUM_APPLIED_VOLUME appliedVolume)
{
var commandParameters = new ArrayList { symbol, (int)period, (int)appliedVolume };
return SendCommand<int>(Mt5CommandType.iVolumes, commandParameters);
}
///<summary>
///The function returns the handle of the Volumes indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="name">The name of the custom indicator, with path relative to the root directory of indicators (MQL5/Indicators/). If an indicator is located in a subdirectory, for example, in MQL5/Indicators/Examples, its name must be specified like: "Examples\\indicator_name" (it is necessary to use a double slash instead of the single slash as a separator).</param>
///<param name="parameters">input-parameters of a custom indicator. If there is no parameters specified, then default values will be used.</param>
public int iCustom(string symbol, ENUM_TIMEFRAMES period, string name, double[] parameters)
{
var response = SendRequest<ICustomResponse>(new ICustomRequest
{
Symbol = symbol,
Timeframe = (int)period,
Name = name,
Params = new ArrayList(parameters),
ParamsType = ICustomRequest.ParametersType.Double
});
return response?.Value ?? 0;
}
///<summary>
///The function returns the handle of the Volumes indicator.
///</summary>
///<param name="symbol">The symbol name of the security, the data of which should be used to calculate the indicator.</param>
///<param name="period">The value of the period can be one of the ENUM_TIMEFRAMES enumeration values, 0 means the current timeframe.</param>
///<param name="name">The name of the custom indicator, with path relative to the root directory of indicators (MQL5/Indicators/). If an indicator is located in a subdirectory, for example, in MQL5/Indicators/Examples, its name must be specified like: "Examples\\indicator_name" (it is necessary to use a double slash instead of the single slash as a separator).</param>
///<param name="parameters">input-parameters of a custom indicator. If there is no parameters specified, then default values will be used.</param>
public int iCustom(string symbol, ENUM_TIMEFRAMES period, string name, int[] parameters)
{
var response = SendRequest<ICustomResponse>(new ICustomRequest
{
Symbol = symbol,
Timeframe = (int)period,
Name = name,
Params = new ArrayList(parameters),
ParamsType = ICustomRequest.ParametersType.Int
});
return response?.Value ?? 0;
}
#endregion // Public Methods
#region Properties
///<summary>
@@ -1671,8 +2450,7 @@ namespace MtApi5
private void OnConnected()
{
// INFO: disabled backtesting mode while solution of window handle in testing mode is not found
//_isBacktestingMode = IsTestMode();
_isBacktestingMode = IsTesting();
if (_isBacktestingMode)
{
+1 -1
View File
@@ -149,7 +149,7 @@ namespace MtApi5
return new ArrayList { (int)request.Action, request.Magic, request.Order, request.Symbol, request.Volume
, request.Price, request.Stoplimit, request.Sl, request.Tp, request.Deviation, (int)request.Type
, (int)request.Type_filling, (int)request.Type_time, exp, request.Comment };
, (int)request.Type_filling, (int)request.Type_time, exp, request.Comment, request.Position, request.PositionBy };
}
#endregion
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.12")]
[assembly: AssemblyFileVersion("1.0.12")]
[assembly: AssemblyVersion("1.0.15")]
[assembly: AssemblyFileVersion("1.0.15")]
+23
View File
@@ -0,0 +1,23 @@
using System.Collections;
namespace MtApi5.Requests
{
internal class ICustomRequest : RequestBase
{
public enum ParametersType
{
Int = 0,
Double = 1,
String = 2,
Boolean = 3
}
public string Symbol { get; set; }
public int Timeframe { get; set; }
public string Name { get; set; }
public ArrayList Params { get; set; }
public ParametersType ParamsType { get; set; }
public override RequestType RequestType => RequestType.iCustom;
}
}
+2 -1
View File
@@ -3,6 +3,7 @@
internal enum RequestType
{
Unknown = 0,
CopyTicks = 1
CopyTicks = 1,
iCustom = 2
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace MtApi5.Responses
{
internal class ICustomResponse: ResponseBase
{
public int Value { get; set; }
}
}
+7 -2
View File
@@ -254,8 +254,13 @@
</Grid>
</Expander>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Button Content="OrderSend" Command="{Binding OrderSendCommand}" Width="100" Height="25"/>
<StackPanel Grid.Row="1" Orientation="Vertical">
<Button Content="OrderSend" Command="{Binding OrderSendCommand}" Width="100" Height="25" HorizontalAlignment="Left" Margin="4"/>
<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"/>
</StackPanel>
</Grid>
+76 -5
View File
@@ -16,6 +16,11 @@ namespace MtApi5TestClient
public DelegateCommand DisconnectCommand { get; private set; }
public DelegateCommand OrderSendCommand { get; private set; }
public DelegateCommand HistoryOrderGetIntegerCommand { get; private set; }
public DelegateCommand HistoryDealGetDoubleCommand { get; private set; }
public DelegateCommand HistoryDealGetIntegerCommand { get; private set; }
public DelegateCommand HistoryDealGetStringCommand { get; private set; }
public DelegateCommand HistoryDealMethodsCommand { get; private set; }
public DelegateCommand AccountInfoDoubleCommand { get; private set; }
public DelegateCommand AccountInfoIntegerCommand { get; private set; }
@@ -193,6 +198,11 @@ namespace MtApi5TestClient
DisconnectCommand = new DelegateCommand(ExecuteDisconnect, CanExecuteDisconnect);
OrderSendCommand = new DelegateCommand(ExecuteOrderSend);
HistoryOrderGetIntegerCommand = new DelegateCommand(ExecuteHistoryOrderGetInteger);
HistoryDealGetDoubleCommand = new DelegateCommand(ExecuteHistoryDealGetDouble);
HistoryDealGetIntegerCommand = new DelegateCommand(ExecuteHistoryDealGetInteger);
HistoryDealGetStringCommand = new DelegateCommand(ExecuteHistoryDealGetString);
HistoryDealMethodsCommand = new DelegateCommand(ExecuteHistoryDealMethods);
AccountInfoDoubleCommand = new DelegateCommand(ExecuteAccountInfoDouble);
AccountInfoIntegerCommand = new DelegateCommand(ExecuteAccountInfoInteger);
@@ -271,6 +281,66 @@ namespace MtApi5TestClient
AddLog(message);
}
private async void ExecuteHistoryOrderGetInteger(object o)
{
const ulong ticket = 12345;
const ENUM_ORDER_PROPERTY_INTEGER propertyId = ENUM_ORDER_PROPERTY_INTEGER.ORDER_POSITION_ID;
var retVal = await Execute(() => _mtApiClient.HistoryOrderGetInteger(ticket, propertyId));
AddLog($"HistoryOrderGetInteger: {retVal}");
}
private async void ExecuteHistoryDealGetDouble(object o)
{
const ulong ticket = 12345;
const ENUM_DEAL_PROPERTY_DOUBLE propertyId = ENUM_DEAL_PROPERTY_DOUBLE.DEAL_PROFIT;
var retVal = await Execute(() => _mtApiClient.HistoryDealGetDouble(ticket, propertyId));
AddLog($"HistoryDealGetDouble: {retVal}");
}
private async void ExecuteHistoryDealGetInteger(object o)
{
const ulong ticket = 12345;
const ENUM_DEAL_PROPERTY_INTEGER propertyId = ENUM_DEAL_PROPERTY_INTEGER.DEAL_TICKET;
var retVal = await Execute(() => _mtApiClient.HistoryDealGetInteger(ticket, propertyId));
AddLog($"HistoryDealGetInteger: {retVal}");
}
private async void ExecuteHistoryDealGetString(object o)
{
const ulong ticket = 12345;
const ENUM_DEAL_PROPERTY_STRING propertyId = ENUM_DEAL_PROPERTY_STRING.DEAL_SYMBOL;
var retVal = await Execute(() => _mtApiClient.HistoryDealGetString(ticket, propertyId));
AddLog($"HistoryDealGetString: {retVal}");
}
private async void ExecuteHistoryDealMethods(object o)
{
try
{
var posId = await Execute(() => _mtApiClient.PositionGetInteger(ENUM_POSITION_PROPERTY_INTEGER.POSITION_IDENTIFIER)); // posId = 7247951
var history = await Execute(() => _mtApiClient.HistorySelectByPosition(posId)); // history = true
var historyDealsTotal = await Execute(() => _mtApiClient.HistoryDealsTotal()); // historyDealsCount = 4
var histDealTicket = await Execute(() => _mtApiClient.HistoryDealGetTicket(0)); // histDealTicket = 6632442
var histDealPrice = await Execute(() => _mtApiClient.HistoryDealGetDouble(histDealTicket, ENUM_DEAL_PROPERTY_DOUBLE.DEAL_PRICE)); // Exception
}
catch (Exception ex)
{
// ex.Messsage = "Service connection failed! Ошибка сериализации параметра http://tempuri.org/:command. Сообщение InnerException было \"Тип \"MtApi5.ENUM_DEAL_PROPERTY_DOUBLE\" с именем контракта данных \"ENUM_DEAL_PROPERTY_DOUBLE:http://schemas.datacontract.org/2004/07/MtApi5\" не ожидается. Попробуйте использовать DataContractResolver, если вы используете DataContractSerializer, или добавьте любые статически неизвестные типы в список известных типов - например, используя атрибут KnownTypeAttribute или путем их добавления в список известных типов, передаваемый в сериализатор.\". Подробнее см. InnerException."
AddLog(ex.Message);
return;
}
AddLog("ExecuteHistoryDealMethods: success.");
}
private async void ExecuteAccountInfoDouble(object o)
{
var result = await Execute(() => _mtApiClient.AccountInfoDouble(AccountInfoDoublePropertyId));
@@ -745,13 +815,14 @@ namespace MtApi5TestClient
const string symbol = "EURUSD";
const ENUM_ORDER_TYPE orderType = ENUM_ORDER_TYPE.ORDER_TYPE_BUY;
const double volume = 0.1;
const double price = 1.013;
const double sl = 1.00;
const double tp = 1.020;
const double price = 1.18129;
const double sl = 1.1811;
const double tp = 1.1814;
const string comment = "Test PositionOpen";
MqlTradeResult tradeResult = null;
var retVal = await Execute (() => _mtApiClient.PositionOpen(symbol, orderType, volume, price, sl, tp, comment));
AddLog($"PositionOpen: symbol EURUSD result = {retVal}");
var retVal = await Execute (() => _mtApiClient.PositionOpen(symbol, orderType, volume, price, sl, tp, comment, out tradeResult));
AddLog($"PositionOpen: symbol EURUSD retVal = {retVal}, result = {tradeResult}");
}
private async void ExecutePrint(object obj)
+78 -65
View File
@@ -113,6 +113,13 @@
this.label22 = new System.Windows.Forms.Label();
this.textBoxErrorCode = new System.Windows.Forms.TextBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.button70 = new System.Windows.Forms.Button();
this.label33 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.label31 = new System.Windows.Forms.Label();
this.textBoxAccountHost = new System.Windows.Forms.TextBox();
this.textBoxAccountPassword = new System.Windows.Forms.TextBox();
this.textBoxAccountLogin = new System.Windows.Forms.TextBox();
this.button67 = new System.Windows.Forms.Button();
this.button66 = new System.Windows.Forms.Button();
this.button65 = new System.Windows.Forms.Button();
@@ -182,6 +189,7 @@
this.button14 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.tabPage7 = new System.Windows.Forms.TabPage();
this.button71 = new System.Windows.Forms.Button();
this.button23 = new System.Windows.Forms.Button();
this.iCustomBtn = new System.Windows.Forms.Button();
this.tabPage8 = new System.Windows.Forms.TabPage();
@@ -202,13 +210,6 @@
this.button4 = new System.Windows.Forms.Button();
this.tabPage11 = new System.Windows.Forms.TabPage();
this.button69 = new System.Windows.Forms.Button();
this.textBoxAccountLogin = new System.Windows.Forms.TextBox();
this.textBoxAccountPassword = new System.Windows.Forms.TextBox();
this.label31 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.textBoxAccountHost = new System.Windows.Forms.TextBox();
this.label33 = new System.Windows.Forms.Label();
this.button70 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -1154,6 +1155,64 @@
this.tabPage3.Text = "Account Information";
this.tabPage3.UseVisualStyleBackColor = true;
//
// button70
//
this.button70.Location = new System.Drawing.Point(371, 292);
this.button70.Name = "button70";
this.button70.Size = new System.Drawing.Size(97, 23);
this.button70.TabIndex = 18;
this.button70.Text = "ChangeAccount";
this.button70.UseVisualStyleBackColor = true;
this.button70.Click += new System.EventHandler(this.button70_Click);
//
// label33
//
this.label33.AutoSize = true;
this.label33.Location = new System.Drawing.Point(168, 269);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(66, 13);
this.label33.TabIndex = 17;
this.label33.Text = "MT4 Server:";
//
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(168, 241);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(56, 13);
this.label32.TabIndex = 17;
this.label32.Text = "Password:";
//
// label31
//
this.label31.AutoSize = true;
this.label31.Location = new System.Drawing.Point(168, 214);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(36, 13);
this.label31.TabIndex = 17;
this.label31.Text = "Login:";
//
// textBoxAccountHost
//
this.textBoxAccountHost.Location = new System.Drawing.Point(234, 266);
this.textBoxAccountHost.Name = "textBoxAccountHost";
this.textBoxAccountHost.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountHost.TabIndex = 17;
//
// textBoxAccountPassword
//
this.textBoxAccountPassword.Location = new System.Drawing.Point(234, 238);
this.textBoxAccountPassword.Name = "textBoxAccountPassword";
this.textBoxAccountPassword.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountPassword.TabIndex = 16;
//
// textBoxAccountLogin
//
this.textBoxAccountLogin.Location = new System.Drawing.Point(232, 212);
this.textBoxAccountLogin.Name = "textBoxAccountLogin";
this.textBoxAccountLogin.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountLogin.TabIndex = 15;
//
// button67
//
this.button67.Location = new System.Drawing.Point(157, 33);
@@ -1836,6 +1895,7 @@
//
// tabPage7
//
this.tabPage7.Controls.Add(this.button71);
this.tabPage7.Controls.Add(this.button23);
this.tabPage7.Controls.Add(this.iCustomBtn);
this.tabPage7.Location = new System.Drawing.Point(4, 40);
@@ -1846,6 +1906,16 @@
this.tabPage7.Text = "Technical Indicators";
this.tabPage7.UseVisualStyleBackColor = true;
//
// button71
//
this.button71.Location = new System.Drawing.Point(6, 64);
this.button71.Name = "button71";
this.button71.Size = new System.Drawing.Size(107, 23);
this.button71.TabIndex = 17;
this.button71.Text = "iBarShift";
this.button71.UseVisualStyleBackColor = true;
this.button71.Click += new System.EventHandler(this.button71_Click);
//
// button23
//
this.button23.Location = new System.Drawing.Point(6, 35);
@@ -2076,64 +2146,6 @@
this.button69.UseVisualStyleBackColor = true;
this.button69.Click += new System.EventHandler(this.button69_Click);
//
// textBoxAccountLogin
//
this.textBoxAccountLogin.Location = new System.Drawing.Point(232, 212);
this.textBoxAccountLogin.Name = "textBoxAccountLogin";
this.textBoxAccountLogin.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountLogin.TabIndex = 15;
//
// textBoxAccountPassword
//
this.textBoxAccountPassword.Location = new System.Drawing.Point(234, 238);
this.textBoxAccountPassword.Name = "textBoxAccountPassword";
this.textBoxAccountPassword.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountPassword.TabIndex = 16;
//
// label31
//
this.label31.AutoSize = true;
this.label31.Location = new System.Drawing.Point(168, 214);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(36, 13);
this.label31.TabIndex = 17;
this.label31.Text = "Login:";
//
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(168, 241);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(56, 13);
this.label32.TabIndex = 17;
this.label32.Text = "Password:";
//
// textBoxAccountHost
//
this.textBoxAccountHost.Location = new System.Drawing.Point(234, 266);
this.textBoxAccountHost.Name = "textBoxAccountHost";
this.textBoxAccountHost.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountHost.TabIndex = 17;
//
// label33
//
this.label33.AutoSize = true;
this.label33.Location = new System.Drawing.Point(168, 269);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(66, 13);
this.label33.TabIndex = 17;
this.label33.Text = "MT4 Server:";
//
// button70
//
this.button70.Location = new System.Drawing.Point(371, 292);
this.button70.Name = "button70";
this.button70.Size = new System.Drawing.Size(97, 23);
this.button70.TabIndex = 18;
this.button70.Text = "ChangeAccount";
this.button70.UseVisualStyleBackColor = true;
this.button70.Click += new System.EventHandler(this.button70_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2366,6 +2378,7 @@
private System.Windows.Forms.TextBox textBoxAccountPassword;
private System.Windows.Forms.TextBox textBoxAccountLogin;
private System.Windows.Forms.Button button70;
private System.Windows.Forms.Button button71;
}
}
+16
View File
@@ -1462,5 +1462,21 @@ namespace TestApiClientUI
var result = await Execute(() => _apiClient.ChangeAccount(login, password, host));
PrintLog($"ChangeAccount result: {result}");
}
//iBarShift
private async void button71_Click(object sender, EventArgs e)
{
const string symbol = "EURUSD";
const ChartPeriod timeframe = ChartPeriod.PERIOD_D1;
var time1 = _apiClient.TimeCurrent();
var time2 = _apiClient.iTime(symbol, timeframe, 5);
var result1 = await Execute(() => _apiClient.iBarShift(symbol, timeframe, time1, true));
var result2 = await Execute(() => _apiClient.iBarShift(symbol, timeframe, time2, true));
PrintLog($"iBarShift result1 = {result1}, time = {time1}");
PrintLog($"iBarShift result2 = {result2}, time = {time2}");
}
}
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+5231 -1458
View File
File diff suppressed because it is too large Load Diff