mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 19:17:48 +00:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be8a17c0fd | |||
| 5c6751de9b | |||
| 83776f8b7a | |||
| f1c1df1e00 | |||
| d6640300f5 | |||
| c9c188f697 | |||
| 3a4f561836 | |||
| bdb30edee3 | |||
| 29f501b055 | |||
| 521d7ea2c0 | |||
| 0e5bb40a6f | |||
| 14079dc3c1 | |||
| 3600a86971 | |||
| 83e62fbff7 | |||
| 5c96aeb2fd | |||
| a238e5eb36 | |||
| 11fd5b7527 | |||
| cbe75cfbf6 | |||
| 9581431a9f | |||
| acf0c12531 | |||
| 1eccda9b2c | |||
| fd4aac7c32 | |||
| 36c90c8481 | |||
| fefa451371 | |||
| 1c57f88cb1 | |||
| 08ba45c65f | |||
| b8314e9ed7 | |||
| 9587b10c8c |
@@ -8,6 +8,50 @@ using log4net.Repository.Hierarchy;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
public class MtLog
|
||||
{
|
||||
#region ctor
|
||||
internal MtLog(Type type)
|
||||
{
|
||||
_log = LogManager.GetLogger(type);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
|
||||
public void Debug(object message)
|
||||
{
|
||||
_log.Debug(message);
|
||||
}
|
||||
|
||||
public void Error(object message)
|
||||
{
|
||||
_log.Error(message);
|
||||
}
|
||||
|
||||
public void Fatal(object message)
|
||||
{
|
||||
_log.Fatal(message);
|
||||
}
|
||||
|
||||
public void Info(object message)
|
||||
{
|
||||
_log.Info(message);
|
||||
}
|
||||
|
||||
public void Warn(object message)
|
||||
{
|
||||
_log.Warn(message);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private
|
||||
|
||||
private readonly ILog _log;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class LogConfigurator
|
||||
{
|
||||
private const string LogFileNameExtension = "txt";
|
||||
@@ -48,5 +92,13 @@ namespace MTApiService
|
||||
#endif
|
||||
hierarchy.Configured = true;
|
||||
}
|
||||
|
||||
public static MtLog GetLogger(Type type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
return new MtLog(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.28.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.28.0")]
|
||||
[assembly: AssemblyVersion("1.0.29.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.29.0")]
|
||||
@@ -994,6 +994,12 @@ namespace MtApi
|
||||
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
|
||||
}
|
||||
|
||||
public DateTime TimeGMT()
|
||||
{
|
||||
var commandResponse = SendCommand<int>(MtCommandType.TimeGMT, null);
|
||||
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
|
||||
}
|
||||
|
||||
public int TimeDay(DateTime date)
|
||||
{
|
||||
var commandParameters = new ArrayList { MtApiTimeConverter.ConvertToMtTime(date) };
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
TimeSeconds = 86,
|
||||
TimeYear = 87,
|
||||
Year = 88,
|
||||
TimeGMT = 281,
|
||||
|
||||
//Global Variables
|
||||
GlobalVariableCheck = 89,
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
namespace MtApi
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
public enum ENUM_TERMINAL_INFO_STRING
|
||||
{
|
||||
|
||||
@@ -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.40.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.40.0")]
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
namespace MtApi5
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTradeCheckResult
|
||||
{
|
||||
public uint Retcode { get; private set; } // Reply code
|
||||
public double Balance { get; private set; } // Balance after the execution of the deal
|
||||
public double Equity { get; private set; } // Equity after the execution of the deal
|
||||
public double Profit { get; private set; } // Floating profit
|
||||
public double Margin { get; private set; } // Margin requirements
|
||||
public double Margin_free { get; private set; } // Free margin
|
||||
public double Margin_level { get; private set; } // Margin level
|
||||
public string Comment { get; private set; } // Comment to the reply code (description of the error)
|
||||
public uint Retcode { get; } // 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 MqlTradeCheckResult(uint retcode
|
||||
, double balance
|
||||
@@ -29,5 +31,10 @@
|
||||
Margin_level = margin_level;
|
||||
Comment = comment;
|
||||
}
|
||||
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
@@ -21,5 +22,12 @@ namespace MtApi5
|
||||
public string Comment { get; set; } // Order comment
|
||||
public ulong Position { get; set; } // Position ticket
|
||||
public ulong PositionBy { get; set; } // The ticket of an opposite position
|
||||
|
||||
public int MtExpiration => Mt5TimeConverter.ConvertToMtTime(Expiration);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Symbol}|{Volume}|{Price}|{Volume}|{Action}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+26
-11
@@ -1,4 +1,6 @@
|
||||
namespace MtApi5
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTradeResult
|
||||
{
|
||||
@@ -15,19 +17,32 @@
|
||||
Request_id = request_id;
|
||||
}
|
||||
|
||||
public uint Retcode { get; private set; } // Operation return code
|
||||
public ulong Deal { get; private set; } // Deal ticket, if it is performed
|
||||
public ulong Order { get; private set; } // Order ticket, if it is placed
|
||||
public double Volume { get; private set; } // Deal volume, confirmed by broker
|
||||
public double Price { get; private set; } // Deal price, confirmed by broker
|
||||
public double Bid { get; private set; } // Current Bid price
|
||||
public double Ask { get; private set; } // Current Ask price
|
||||
public string Comment { get; private set; } // Broker comment to operation (by default it is filled by the operation description)
|
||||
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch
|
||||
internal MqlTradeResult(MqlTradeResult o)
|
||||
{
|
||||
Retcode = o.Retcode;
|
||||
Deal = o.Deal;
|
||||
Order = o.Order;
|
||||
Volume = o.Volume;
|
||||
Price = o.Price;
|
||||
Bid = o.Bid;
|
||||
Ask = o.Ask;
|
||||
Comment = o.Comment;
|
||||
Request_id = o.Request_id;
|
||||
}
|
||||
|
||||
public uint Retcode { get; } // Operation return code
|
||||
public ulong Deal { get; } // Deal ticket, if it is performed
|
||||
public ulong Order { get; } // Order ticket, if it is placed
|
||||
public double Volume { get; } // Deal volume, confirmed by broker
|
||||
public double Price { get; } // Deal price, confirmed by broker
|
||||
public double Bid { get; } // Current Bid price
|
||||
public double Ask { get; } // Current Ask price
|
||||
public string Comment { get; } // Broker comment to operation (by default it is filled by the operation description)
|
||||
public uint Request_id { get; } // Request ID set by the terminal during the dispatch
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Retcode={Retcode}; Deal={Deal}; Order={Order}; Volume={Volume}; Price={Price}; Bid={Bid}; Ask={Ask}; Comment={Comment}; Request_id={Request_id}";
|
||||
return $"Retcode={Retcode}; Comment={Comment}; Deal={Deal}; Order={Order}; Volume={Volume}; Price={Price}; Bid={Bid}; Ask={Ask}; Request_id={Request_id}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
namespace MtApi5
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace MtApi5
|
||||
{
|
||||
internal enum Mt5CommandType
|
||||
{
|
||||
//NoCommand = 0
|
||||
|
||||
//trade operations
|
||||
OrderSend = 1,
|
||||
//OrderSend = 1,
|
||||
OrderCalcMargin = 2,
|
||||
OrderCalcProfit = 3,
|
||||
OrderCheck = 4,
|
||||
//OrderCheck = 4,
|
||||
//OrderSendAsync = 5,
|
||||
PositionsTotal = 6,
|
||||
PositionGetSymbol = 7,
|
||||
@@ -100,7 +101,7 @@
|
||||
//CTrade
|
||||
PositionClose = 64,
|
||||
PositionOpen = 65,
|
||||
PositionOpenWithResult = 1065,
|
||||
//PositionOpenWithResult = 1065,
|
||||
|
||||
//Backtesting
|
||||
BacktestingReady = 66,
|
||||
@@ -130,6 +131,52 @@
|
||||
ObjectSetString = 84,
|
||||
//TextSetFont = 85,
|
||||
//TextOut = 86,
|
||||
//TextGetSize = 87
|
||||
//TextGetSize = 87,
|
||||
|
||||
iAC = 88,
|
||||
iAD = 89,
|
||||
iADX = 90,
|
||||
iADXWilder = 91,
|
||||
iAlligator = 92,
|
||||
iAMA = 93,
|
||||
iAO = 94,
|
||||
iATR = 95,
|
||||
iBearsPower = 96,
|
||||
iBands = 97,
|
||||
iBullsPower = 98,
|
||||
iCCI = 99,
|
||||
iChaikin = 100,
|
||||
//iCustom = 101,
|
||||
iDEMA = 102,
|
||||
iDeMarker = 103,
|
||||
iEnvelopes = 104,
|
||||
iForce = 105,
|
||||
iFractals = 106,
|
||||
iFrAMA = 107,
|
||||
iGator = 108,
|
||||
iIchimoku = 109,
|
||||
iBWMFI = 110,
|
||||
iMomentum = 111,
|
||||
iMFI = 112,
|
||||
iMA = 113,
|
||||
iOsMA = 114,
|
||||
iMACD = 115,
|
||||
iOBV = 116,
|
||||
iSAR = 117,
|
||||
iRSI = 118,
|
||||
iRVI = 119,
|
||||
iStdDev = 120,
|
||||
iStochastic = 121,
|
||||
iTEMA = 122,
|
||||
iTriX = 123,
|
||||
iWPR = 124,
|
||||
iVIDyA = 125,
|
||||
iVolumes = 126,
|
||||
|
||||
//Date and Time
|
||||
TimeCurrent = 127,
|
||||
TimeTradeServer = 128,
|
||||
TimeLocal = 129,
|
||||
TimeGMT = 130
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace MtApi5
|
||||
{
|
||||
public class Mt5ConnectionEventArgs: EventArgs
|
||||
{
|
||||
public Mt5ConnectionState Status { get; private set; }
|
||||
public string ConnectionMessage { get; private set; }
|
||||
public Mt5ConnectionState Status { get; }
|
||||
public string ConnectionMessage { get; }
|
||||
|
||||
public Mt5ConnectionEventArgs(Mt5ConnectionState status, string message)
|
||||
{
|
||||
|
||||
+44
-3
@@ -1,4 +1,6 @@
|
||||
namespace MtApi5
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
|
||||
// Chart Constants:
|
||||
@@ -742,5 +744,44 @@
|
||||
ALIGN_CENTER = 2, // Centered (only for the Edit object)
|
||||
ALIGN_RIGHT = 0, // Right alignment
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#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
|
||||
}
|
||||
|
||||
+4
-9
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5Quote
|
||||
{
|
||||
public string Instrument { get; private set; }
|
||||
public double Bid { get; private set; }
|
||||
public double Ask { get; private set; }
|
||||
public string Instrument { get; }
|
||||
public double Bid { get; }
|
||||
public double Ask { get; }
|
||||
|
||||
public Mt5Quote(string instrument, double bid, double ask)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5QuoteEventArgs: EventArgs
|
||||
{
|
||||
public Mt5Quote Quote { get; private set; }
|
||||
public Mt5Quote Quote { get; }
|
||||
|
||||
public Mt5QuoteEventArgs(Mt5Quote quote)
|
||||
{
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
class Mt5TimeConverter
|
||||
internal class Mt5TimeConverter
|
||||
{
|
||||
public static DateTime ConvertFromMtTime(int time)
|
||||
{
|
||||
DateTime tmpTime = new DateTime(1970, 1, 1);
|
||||
var tmpTime = new DateTime(1970, 1, 1);
|
||||
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
||||
}
|
||||
|
||||
public static DateTime ConvertFromMtTime(long time)
|
||||
{
|
||||
DateTime tmpTime = new DateTime(1970, 1, 1);
|
||||
var tmpTime = new DateTime(1970, 1, 1);
|
||||
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
||||
}
|
||||
|
||||
public static int ConvertToMtTime(DateTime time)
|
||||
{
|
||||
int result = 0;
|
||||
if (time != DateTime.MinValue)
|
||||
{
|
||||
DateTime tmpTime = new DateTime(1970, 1, 1);
|
||||
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||
}
|
||||
var result = 0;
|
||||
if (time == DateTime.MinValue) return result;
|
||||
var tmpTime = new DateTime(1970, 1, 1);
|
||||
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,15 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Mt5Quote.cs" />
|
||||
<Compile Include="Requests\CopyTicksRequest.cs" />
|
||||
<Compile Include="Requests\ICustomRequest.cs" />
|
||||
<Compile Include="Requests\OrderCheckRequest.cs" />
|
||||
<Compile Include="Requests\OrderCheckResult.cs" />
|
||||
<Compile Include="Requests\OrderSendRequest.cs" />
|
||||
<Compile Include="Requests\PositionOpenRequest.cs" />
|
||||
<Compile Include="Requests\RequestBase.cs" />
|
||||
<Compile Include="Requests\RequestType.cs" />
|
||||
<Compile Include="Responses\CopyTicksResponse.cs" />
|
||||
<Compile Include="Responses\ResponseBase.cs" />
|
||||
<Compile Include="Requests\OrderSendResult.cs" />
|
||||
<Compile Include="Requests\Response.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
|
||||
@@ -81,6 +86,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
+725
-35
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MTApiService;
|
||||
using System.Collections;
|
||||
using System.ServiceModel;
|
||||
using MtApi5.Requests;
|
||||
using MtApi5.Responses;
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -32,9 +32,11 @@ namespace MtApi5
|
||||
|
||||
|
||||
#region Private Fields
|
||||
private static readonly MtLog Log = LogConfigurator.GetLogger(typeof(MtApi5Client));
|
||||
|
||||
private MtClient _client;
|
||||
private readonly object _locker = new object();
|
||||
private volatile bool _isBacktestingMode = false;
|
||||
private volatile bool _isBacktestingMode;
|
||||
private Mt5ConnectionState _connectionState = Mt5ConnectionState.Disconnected;
|
||||
private int _executorHandle;
|
||||
#endregion
|
||||
@@ -78,8 +80,8 @@ namespace MtApi5
|
||||
public IEnumerable<Mt5Quote> GetQuotes()
|
||||
{
|
||||
var client = Client;
|
||||
var quotes = client != null ? client.GetQuotes() : null;
|
||||
return quotes?.Select(q => q.Parse());
|
||||
var quotes = client?.GetQuotes();
|
||||
return quotes?.Select(q => q.Convert());
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -104,17 +106,22 @@ namespace MtApi5
|
||||
/// </returns>
|
||||
public bool OrderSend(MqlTradeRequest request, out MqlTradeResult result)
|
||||
{
|
||||
Log.Debug($"OrderSend: request = {request}");
|
||||
|
||||
if (request == null)
|
||||
{
|
||||
Log.Warn("OrderSend: request is not defined!");
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var commandParameters = request.ToArrayList();
|
||||
var response = SendRequest<OrderSendResult>(new OrderSendRequest
|
||||
{
|
||||
TradeRequest = request
|
||||
});
|
||||
|
||||
var strResult = SendCommand<string>(Mt5CommandType.OrderSend, commandParameters);
|
||||
|
||||
return strResult.ParseResult(ParamSeparator, out result);
|
||||
result = response?.TradeResult;
|
||||
return response != null && response.RetVal;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -180,17 +187,22 @@ namespace MtApi5
|
||||
/// </returns>
|
||||
public bool OrderCheck(MqlTradeRequest request, out MqlTradeCheckResult result)
|
||||
{
|
||||
Log.Debug($"OrderCheck: request = {request}");
|
||||
|
||||
if (request == null)
|
||||
{
|
||||
Log.Warn("OrderCheck: request is not defined!");
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var commandParameters = request.ToArrayList();
|
||||
var response = SendRequest<OrderCheckResult>(new OrderCheckRequest
|
||||
{
|
||||
TradeRequest = request
|
||||
});
|
||||
|
||||
var strResult = SendCommand<string>(Mt5CommandType.OrderSend, commandParameters);
|
||||
|
||||
return strResult.ParseResult(ParamSeparator, out result);
|
||||
result = response?.TradeCheckResult;
|
||||
return response != null && response.RetVal;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -456,7 +468,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 +480,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 +492,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);
|
||||
}
|
||||
@@ -533,13 +545,25 @@ namespace MtApi5
|
||||
/// <param name="sl">Stop Loss price</param>
|
||||
/// <param name="tp">Take Profit price</param>
|
||||
/// <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)
|
||||
{
|
||||
var commandParameters = new ArrayList { symbol, (int)orderType, volume, price, sl, tp, comment };
|
||||
Log.Debug($"PositionOpen: symbol = {symbol}, orderType = {orderType}, volume = {volume}, price = {price}, sl = {sl}, tp = {tp}, comment = {comment}");
|
||||
|
||||
var strResult = SendCommand<string>(Mt5CommandType.PositionOpenWithResult, commandParameters);
|
||||
return strResult.ParseResult(ParamSeparator, out result);
|
||||
var response = SendRequest<OrderSendResult>(new PositionOpenRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
OrderType = orderType,
|
||||
Volume = volume,
|
||||
Price = price,
|
||||
Sl = sl,
|
||||
Tp = tp,
|
||||
Comment = comment
|
||||
});
|
||||
|
||||
result = response?.TradeResult;
|
||||
return response != null && response.RetVal;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -711,7 +735,7 @@ namespace MtApi5
|
||||
|
||||
return ratesArray?.Length ?? 0;
|
||||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///Gets history data of MqlRates structure of a specified symbol-period in specified quantity into the ratesArray array. The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar.
|
||||
///</summary>
|
||||
@@ -1229,11 +1253,14 @@ namespace MtApi5
|
||||
///<see href="https://www.mql5.com/en/docs/series/copyticks"/>
|
||||
public List<MqlTick> CopyTicks(string symbolName, CopyTicksFlag flags = CopyTicksFlag.All, ulong from = 0, uint count = 0)
|
||||
{
|
||||
var response = SendRequest<CopyTicksResponse>(new CopyTicksRequest
|
||||
var response = SendRequest<List<MqlTick>>(new CopyTicksRequest
|
||||
{
|
||||
SymbolName = symbolName, Flags = (int)flags, From = from, Count = count
|
||||
SymbolName = symbolName,
|
||||
Flags = (int)flags,
|
||||
From = from,
|
||||
Count = count
|
||||
});
|
||||
return response.Ticks;
|
||||
return response;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1638,6 +1665,664 @@ namespace MtApi5
|
||||
|
||||
#endregion //Object Functions
|
||||
|
||||
#region 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)
|
||||
{
|
||||
Log.Debug("iCustom: called.");
|
||||
var response = SendRequest<int>(new ICustomRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
Timeframe = (int)period,
|
||||
Name = name,
|
||||
Params = new ArrayList(parameters),
|
||||
ParamsType = ICustomRequest.ParametersType.Double
|
||||
});
|
||||
Log.Debug($"iCustom: response = {response}.");
|
||||
return response;
|
||||
}
|
||||
|
||||
///<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)
|
||||
{
|
||||
Log.Debug("iCustom: called.");
|
||||
var response = SendRequest<int>(new ICustomRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
Timeframe = (int)period,
|
||||
Name = name,
|
||||
Params = new ArrayList(parameters),
|
||||
ParamsType = ICustomRequest.ParametersType.Int
|
||||
});
|
||||
Log.Debug($"iCustom: response = {response}.");
|
||||
return response;
|
||||
}
|
||||
|
||||
///<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, string[] parameters)
|
||||
{
|
||||
Log.Debug("iCustom: called.");
|
||||
var response = SendRequest<int>(new ICustomRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
Timeframe = (int)period,
|
||||
Name = name,
|
||||
Params = new ArrayList(parameters),
|
||||
ParamsType = ICustomRequest.ParametersType.Int
|
||||
});
|
||||
Log.Debug($"iCustom: response = {response}.");
|
||||
return response;
|
||||
}
|
||||
|
||||
///<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, bool[] parameters)
|
||||
{
|
||||
Log.Debug("iCustom: called.");
|
||||
var response = SendRequest<int>(new ICustomRequest
|
||||
{
|
||||
Symbol = symbol,
|
||||
Timeframe = (int)period,
|
||||
Name = name,
|
||||
Params = new ArrayList(parameters),
|
||||
ParamsType = ICustomRequest.ParametersType.Int
|
||||
});
|
||||
Log.Debug($"iCustom: response = {response}.");
|
||||
return response;
|
||||
}
|
||||
|
||||
#endregion //Technical Indicators
|
||||
|
||||
#region Date and Time
|
||||
|
||||
///<summary>
|
||||
///Returns the last known server time, time of the last quote receipt for one of the symbols selected in the "Market Watch" window.
|
||||
///</summary>
|
||||
public DateTime TimeCurrent()
|
||||
{
|
||||
Log.Debug("TimeCurrent: called.");
|
||||
var response = SendCommand<long>(Mt5CommandType.TimeCurrent, null);
|
||||
Log.Debug($"TimeCurrent: response = {response}.");
|
||||
return Mt5TimeConverter.ConvertFromMtTime(response);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the calculated current time of the trade server. Unlike TimeCurrent(), the calculation of the time value is performed in the client terminal and depends on the time settings on your computer.
|
||||
///</summary>
|
||||
public DateTime TimeTradeServer()
|
||||
{
|
||||
Log.Debug("TimeTradeServer: called.");
|
||||
var response = SendCommand<long>(Mt5CommandType.TimeTradeServer, null);
|
||||
Log.Debug($"TimeTradeServer: response = {response}.");
|
||||
return Mt5TimeConverter.ConvertFromMtTime(response);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the local time of a computer, where the client terminal is running.
|
||||
///</summary>
|
||||
public DateTime TimeLocal()
|
||||
{
|
||||
Log.Debug("TimeLocal: called.");
|
||||
var response = SendCommand<long>(Mt5CommandType.TimeLocal, null);
|
||||
Log.Debug($"TimeLocal: response = {response}.");
|
||||
return Mt5TimeConverter.ConvertFromMtTime(response);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the GMT, which is calculated taking into account the DST switch by the local time on the computer where the client terminal is running.
|
||||
///</summary>
|
||||
public DateTime TimeGMT()
|
||||
{
|
||||
Log.Debug("TimeGMT: called.");
|
||||
var response = SendCommand<long>(Mt5CommandType.TimeGMT, null);
|
||||
Log.Debug($"TimeGMT: response = {response}.");
|
||||
return Mt5TimeConverter.ConvertFromMtTime(response);
|
||||
}
|
||||
|
||||
#endregion //Date and Time
|
||||
|
||||
#endregion // Public Methods
|
||||
|
||||
#region Properties
|
||||
@@ -1679,6 +2364,7 @@ namespace MtApi5
|
||||
|
||||
#region Events
|
||||
public event QuoteHandler QuoteUpdated;
|
||||
public event EventHandler<Mt5QuoteEventArgs> QuoteUpdate;
|
||||
public event EventHandler<Mt5QuoteEventArgs> QuoteAdded;
|
||||
public event EventHandler<Mt5QuoteEventArgs> QuoteRemoved;
|
||||
public event EventHandler<Mt5ConnectionEventArgs> ConnectionStateChanged;
|
||||
@@ -1826,10 +2512,10 @@ namespace MtApi5
|
||||
}
|
||||
|
||||
var responseValue = response.GetValue();
|
||||
return responseValue != null ? (T)responseValue : default(T);
|
||||
return (T) responseValue;
|
||||
}
|
||||
|
||||
private T SendRequest<T>(RequestBase request) where T : ResponseBase, new()
|
||||
private T SendRequest<T>(RequestBase request)
|
||||
{
|
||||
if (request == null)
|
||||
return default(T);
|
||||
@@ -1848,22 +2534,21 @@ namespace MtApi5
|
||||
throw new ExecutionException(ErrorCode.ErrCustom, "Response from MetaTrader is null");
|
||||
}
|
||||
|
||||
var response = JsonConvert.DeserializeObject<T>(res);
|
||||
var response = JsonConvert.DeserializeObject<Response<T>>(res);
|
||||
if (response.ErrorCode != 0)
|
||||
{
|
||||
throw new ExecutionException((ErrorCode)response.ErrorCode, response.ErrorMessage);
|
||||
}
|
||||
|
||||
return response;
|
||||
return response.Value;
|
||||
}
|
||||
|
||||
|
||||
private void _client_QuoteUpdated(MtQuote quote)
|
||||
{
|
||||
if (quote != null)
|
||||
{
|
||||
QuoteUpdated?.Invoke(this, quote.Instrument, quote.Bid, quote.Ask);
|
||||
}
|
||||
if (quote == null) return;
|
||||
QuoteUpdate?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask)));
|
||||
QuoteUpdated?.Invoke(this, quote.Instrument, quote.Bid, quote.Ask);
|
||||
}
|
||||
|
||||
private void _client_ServerDisconnected(object sender, EventArgs e)
|
||||
@@ -1878,18 +2563,23 @@ namespace MtApi5
|
||||
|
||||
private void _client_QuoteRemoved(MtQuote quote)
|
||||
{
|
||||
QuoteRemoved?.Invoke(this, new Mt5QuoteEventArgs(quote.Parse()));
|
||||
if (quote != null)
|
||||
{
|
||||
QuoteRemoved?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask)));
|
||||
}
|
||||
}
|
||||
|
||||
private void _client_QuoteAdded(MtQuote quote)
|
||||
{
|
||||
QuoteAdded?.Invoke(this, new Mt5QuoteEventArgs(quote.Parse()));
|
||||
if (quote != null)
|
||||
{
|
||||
QuoteAdded?.Invoke(this, new Mt5QuoteEventArgs(new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask)));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnConnected()
|
||||
{
|
||||
// INFO: disabled backtesting mode while solution of window handle in testing mode is not found
|
||||
//_isBacktestingMode = IsTestMode();
|
||||
_isBacktestingMode = IsTesting();
|
||||
|
||||
if (_isBacktestingMode)
|
||||
{
|
||||
|
||||
+20
-74
@@ -6,84 +6,18 @@ namespace MtApi5
|
||||
{
|
||||
internal static class MtConverters
|
||||
{
|
||||
private static readonly MtLog Log = LogConfigurator.GetLogger(typeof(MtConverters));
|
||||
|
||||
#region Values Converters
|
||||
public static Mt5Quote Parse(this MtQuote quote)
|
||||
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 MqlTradeResult result)
|
||||
{
|
||||
var retVal = false;
|
||||
result = null;
|
||||
|
||||
if (string.IsNullOrEmpty(inputString) == false)
|
||||
{
|
||||
var values = inputString.Split(separator);
|
||||
if (values.Length == 10)
|
||||
{
|
||||
try
|
||||
{
|
||||
retVal = int.Parse(values[0]) != 0;
|
||||
|
||||
var retcode = uint.Parse(values[1]);
|
||||
var deal = ulong.Parse(values[2]);
|
||||
var order = ulong.Parse(values[3]);
|
||||
var volume = double.Parse(values[4]);
|
||||
var price = double.Parse(values[5]);
|
||||
var bid = double.Parse(values[6]);
|
||||
var ask = double.Parse(values[7]);
|
||||
var comment = values[8];
|
||||
var requestId = uint.Parse(values[9]);
|
||||
|
||||
result = new MqlTradeResult(retcode, deal, order, volume, price, bid, ask, comment, requestId);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static bool ParseResult(this string inputString, char separator, out MqlTradeCheckResult result)
|
||||
{
|
||||
var retVal = false;
|
||||
result = null;
|
||||
|
||||
if (string.IsNullOrEmpty(inputString) == false)
|
||||
{
|
||||
var values = inputString.Split(separator);
|
||||
if (values.Length == 10)
|
||||
{
|
||||
try
|
||||
{
|
||||
retVal = int.Parse(values[0]) != 0;
|
||||
|
||||
var retcode = uint.Parse(values[1]);
|
||||
var balance = double.Parse(values[2]);
|
||||
var equity = double.Parse(values[3]);
|
||||
var profit = double.Parse(values[4]);
|
||||
var margin = double.Parse(values[5]);
|
||||
var marginFree = double.Parse(values[6]);
|
||||
var marginLevel = double.Parse(values[7]);
|
||||
var comment = values[8];
|
||||
|
||||
result = new MqlTradeCheckResult(retcode, balance, equity, profit, margin, marginFree, marginLevel, comment);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
return quote != null ? new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask) : null;
|
||||
}
|
||||
|
||||
public static bool ParseResult(this string inputString, char separator, out double result)
|
||||
{
|
||||
Log.Debug($"ParseResult: inputString = {inputString}, separator = {separator}");
|
||||
|
||||
var retVal = false;
|
||||
result = 0;
|
||||
|
||||
@@ -98,18 +32,25 @@ namespace MtApi5
|
||||
|
||||
result = double.Parse(values[1]);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.Error($"ParseResult: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warn("ParseResult: input srting is null or empty!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static bool ParseResult(this string inputString, char separator, out DateTime from, out DateTime to)
|
||||
{
|
||||
Log.Debug($"ParseResult: inputString = {inputString}, separator = {separator}");
|
||||
|
||||
var retVal = false;
|
||||
|
||||
from = new DateTime();
|
||||
@@ -130,12 +71,17 @@ namespace MtApi5
|
||||
var iTo= int.Parse(values[2]);
|
||||
to = Mt5TimeConverter.ConvertFromMtTime(iTo);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.Error($"ParseResult: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warn("ParseResult: input srting is null or empty!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -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.13")]
|
||||
[assembly: AssemblyFileVersion("1.0.13")]
|
||||
[assembly: AssemblyVersion("1.0.16")]
|
||||
[assembly: AssemblyFileVersion("1.0.16")]
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class OrderCheckRequest: RequestBase
|
||||
{
|
||||
public override RequestType RequestType => RequestType.OrderCheck;
|
||||
|
||||
public MqlTradeRequest TradeRequest { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
public class OrderCheckResult
|
||||
{
|
||||
public bool RetVal { get; set; }
|
||||
public MqlTradeCheckResult TradeCheckResult { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class OrderSendRequest: RequestBase
|
||||
{
|
||||
public override RequestType RequestType => RequestType.OrderSend;
|
||||
|
||||
public MqlTradeRequest TradeRequest { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class OrderSendResult
|
||||
{
|
||||
public bool RetVal { get; set; }
|
||||
public MqlTradeResult TradeResult { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class PositionOpenRequest: RequestBase
|
||||
{
|
||||
public override RequestType RequestType => RequestType.PositionOpen;
|
||||
|
||||
public string Symbol { get; set; }
|
||||
public ENUM_ORDER_TYPE OrderType { get; set; }
|
||||
public double Volume { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double Sl { get; set; }
|
||||
public double Tp { get; set; }
|
||||
public string Comment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
namespace MtApi5.Requests
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal enum RequestType
|
||||
{
|
||||
Unknown = 0,
|
||||
CopyTicks = 1
|
||||
CopyTicks = 1,
|
||||
iCustom = 2,
|
||||
OrderSend = 3,
|
||||
PositionOpen = 4,
|
||||
OrderCheck = 5
|
||||
}
|
||||
}
|
||||
Executable → Regular
+4
-2
@@ -1,8 +1,10 @@
|
||||
namespace MtApi5.Responses
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class ResponseBase
|
||||
internal class Response<T>
|
||||
{
|
||||
public int ErrorCode { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public T Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MtApi5.Responses
|
||||
{
|
||||
internal class CopyTicksResponse: ResponseBase
|
||||
{
|
||||
public List<MqlTick> Ticks { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:mtapi5="clr-namespace:MtApi5;assembly=MtApi5"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:mtApi5TestClient="clr-namespace:MtApi5TestClient"
|
||||
Title="MainWindow" Height="700" Width="650"
|
||||
Title="MainWindow" Height="700" Width="700"
|
||||
Closing="Window_Closing">
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="ConnectionTextBlockTemplate" DataType="{x:Type mtapi5:Mt5ConnectionState}">
|
||||
@@ -100,58 +100,33 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Expander ExpandDirection="Right" IsExpanded="True"
|
||||
Grid.Row="0" Grid.Column="0" Margin="5">
|
||||
<Expander.Header>
|
||||
<TextBlock Text="Connection" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" Width="Auto">
|
||||
<TextBlock.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="-90"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</TextBlock.LayoutTransform>
|
||||
<TextBlock.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</TextBlock.RenderTransform>
|
||||
</TextBlock>
|
||||
</Expander.Header>
|
||||
<Expander.Content>
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Host"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1"
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Host"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1"
|
||||
Margin="5,0,0,0"
|
||||
Text="{Binding Host, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Port"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1"
|
||||
<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>
|
||||
</Grid>
|
||||
</Expander.Content>
|
||||
</Expander>
|
||||
<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>
|
||||
</Grid>
|
||||
|
||||
<ListView Grid.Row="0" Grid.Column="1"
|
||||
ItemsSource="{Binding Quotes}"
|
||||
@@ -247,15 +222,26 @@
|
||||
SelectedItem="{Binding TradeRequest.Type_time}" Margin="5,0,0,0"/>
|
||||
|
||||
<TextBlock Grid.Column="2" Grid.Row="6" Text="Expiration" Margin="10,0,0,0"/>
|
||||
<TextBox Grid.Column="3" Grid.Row="6" Text="{Binding TradeRequest}" Margin="5,0,0,0"/>
|
||||
<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}" Margin="5,0,0,0"/>
|
||||
<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="Horizontal">
|
||||
<Button Content="OrderSend" Command="{Binding OrderSendCommand}" Width="100" Height="25"/>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
@@ -397,10 +383,25 @@
|
||||
<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="History" IsExpanded="True">
|
||||
<ListBox mtApi5TestClient:ListBoxBehavior.ScrollOnNewItem="true" Height="200" ItemsSource="{Binding History}"/>
|
||||
<Expander Grid.Row="2" Header="Console" IsExpanded="True">
|
||||
<ListBox mtApi5TestClient:ListBoxBehavior.ScrollOnNewItem="true" Height="180" ItemsSource="{Binding History}"/>
|
||||
</Expander>
|
||||
|
||||
<StatusBar Grid.Row="3">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
@@ -16,6 +17,13 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand DisconnectCommand { get; private set; }
|
||||
|
||||
public DelegateCommand OrderSendCommand { get; private set; }
|
||||
public DelegateCommand OrderCheckCommand { 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; }
|
||||
@@ -50,6 +58,13 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand PositionOpenCommand { get; private set; }
|
||||
|
||||
public DelegateCommand PrintCommand { get; private set; }
|
||||
|
||||
public DelegateCommand iCustomCommand { get; private set; }
|
||||
|
||||
public DelegateCommand TimeCurrentCommand { get; private set; }
|
||||
public DelegateCommand TimeTradeServerCommand { get; private set; }
|
||||
public DelegateCommand TimeLocalCommand { get; private set; }
|
||||
public DelegateCommand TimeGMTCommand { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -193,6 +208,13 @@ namespace MtApi5TestClient
|
||||
DisconnectCommand = new DelegateCommand(ExecuteDisconnect, CanExecuteDisconnect);
|
||||
|
||||
OrderSendCommand = new DelegateCommand(ExecuteOrderSend);
|
||||
OrderCheckCommand = new DelegateCommand(ExecuteOrderCheck);
|
||||
|
||||
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);
|
||||
@@ -227,6 +249,13 @@ namespace MtApi5TestClient
|
||||
PositionOpenCommand = new DelegateCommand(ExecutePositionOpen);
|
||||
|
||||
PrintCommand = new DelegateCommand(ExecutePrint);
|
||||
|
||||
iCustomCommand = new DelegateCommand(ExecuteICustom);
|
||||
|
||||
TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
|
||||
TimeTradeServerCommand = new DelegateCommand(ExecuteTimeTradeServer);
|
||||
TimeLocalCommand = new DelegateCommand(ExecuteTimeLocal);
|
||||
TimeGMTCommand = new DelegateCommand(ExecuteTimeGMT);
|
||||
}
|
||||
|
||||
private bool CanExecuteConnect(object o)
|
||||
@@ -259,18 +288,91 @@ namespace MtApi5TestClient
|
||||
private async void ExecuteOrderSend(object o)
|
||||
{
|
||||
var request = TradeRequest.GetMqlTradeRequest();
|
||||
|
||||
MqlTradeResult result = null;
|
||||
var retVal = await Execute(() =>
|
||||
{
|
||||
MqlTradeResult result;
|
||||
var ok = _mtApiClient.OrderSend(request, out result);
|
||||
return ok ? result : null;
|
||||
return ok;
|
||||
});
|
||||
|
||||
var message = retVal != null ? $"OrderSend successed. {MqlTradeResultToString(retVal)}" : "OrderSend failed.";
|
||||
var message = retVal ? $"OrderSend: success. {result}" : $"OrderSend: fail. {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
|
||||
private async void ExecuteOrderCheck(object obj)
|
||||
{
|
||||
var request = TradeRequest.GetMqlTradeRequest();
|
||||
MqlTradeCheckResult result = null;
|
||||
var retVal = await Execute(() =>
|
||||
{
|
||||
var ok = _mtApiClient.OrderCheck(request, out result);
|
||||
return ok;
|
||||
});
|
||||
|
||||
var message = retVal ? $"OrderCheck: success. {result}" : $"OrderCheck: fail. {result}";
|
||||
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));
|
||||
var history = await Execute(() => _mtApiClient.HistorySelectByPosition(posId));
|
||||
var historyDealsTotal = await Execute(() => _mtApiClient.HistoryDealsTotal());
|
||||
var histDealTicket = await Execute(() => _mtApiClient.HistoryDealGetTicket(0));
|
||||
var histDealPrice = await Execute(() => _mtApiClient.HistoryDealGetDouble(histDealTicket, ENUM_DEAL_PROPERTY_DOUBLE.DEAL_PRICE));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog(ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog("ExecuteHistoryDealMethods: success.");
|
||||
}
|
||||
|
||||
private async void ExecuteAccountInfoDouble(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.AccountInfoDouble(AccountInfoDoublePropertyId));
|
||||
@@ -763,6 +865,41 @@ namespace MtApi5TestClient
|
||||
AddLog($"Print: message print in MetaTrader - {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteICustom(object o)
|
||||
{
|
||||
const string symbol = "EURUSD";
|
||||
const ENUM_TIMEFRAMES timeframe = ENUM_TIMEFRAMES.PERIOD_H1;
|
||||
const string name = @"Examples\Custom Moving Average";
|
||||
int[] parameters = { 0, 21, (int)ENUM_APPLIED_PRICE.PRICE_CLOSE };
|
||||
|
||||
var retVal = await Execute(() => _mtApiClient.iCustom(symbol, timeframe, name, parameters));
|
||||
AddLog($"Custom Moving Average: result - {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteTimeCurrent(object o)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.TimeCurrent());
|
||||
AddLog($"TimeCurrent: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteTimeTradeServer(object o)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.TimeTradeServer());
|
||||
AddLog($"TimeTradeServer: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteTimeLocal(object o)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.TimeLocal());
|
||||
AddLog($"TimeLocal: {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteTimeGMT(object o)
|
||||
{
|
||||
var retVal = await Execute(() => _mtApiClient.TimeGMT());
|
||||
AddLog($"TimeGMT: {retVal}");
|
||||
}
|
||||
|
||||
private static void RunOnUiThread(Action action)
|
||||
{
|
||||
Application.Current?.Dispatcher.Invoke(action);
|
||||
@@ -885,20 +1022,6 @@ namespace MtApi5TestClient
|
||||
Quotes.Clear();
|
||||
}
|
||||
|
||||
private static string MqlTradeResultToString(MqlTradeResult result)
|
||||
{
|
||||
return result != null ?
|
||||
"Retcode = " + result.Retcode + ";"
|
||||
+ " Comment = " + result.Comment + ";"
|
||||
+ " Order = " + result.Order + ";"
|
||||
+ " Volume = " + result.Volume + ";"
|
||||
+ " Price = " + result.Price + ";"
|
||||
+ " Deal = " + result.Deal + ";"
|
||||
+ " Request_id = " + result.Request_id + ";"
|
||||
+ " Bid = " + result.Bid + ";"
|
||||
+ " Ask = " + result.Ask + ";" : string.Empty;
|
||||
}
|
||||
|
||||
private void OnSelectedQuoteChanged()
|
||||
{
|
||||
if (SelectedQuote == null) return;
|
||||
|
||||
+116
-65
@@ -113,6 +113,13 @@
|
||||
this.label22 = new System.Windows.Forms.Label();
|
||||
this.textBoxErrorCode = new System.Windows.Forms.TextBox();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.button70 = new System.Windows.Forms.Button();
|
||||
this.label33 = new System.Windows.Forms.Label();
|
||||
this.label32 = new System.Windows.Forms.Label();
|
||||
this.label31 = new System.Windows.Forms.Label();
|
||||
this.textBoxAccountHost = new System.Windows.Forms.TextBox();
|
||||
this.textBoxAccountPassword = new System.Windows.Forms.TextBox();
|
||||
this.textBoxAccountLogin = new System.Windows.Forms.TextBox();
|
||||
this.button67 = new System.Windows.Forms.Button();
|
||||
this.button66 = new System.Windows.Forms.Button();
|
||||
this.button65 = new System.Windows.Forms.Button();
|
||||
@@ -136,6 +143,8 @@
|
||||
this.label23 = new System.Windows.Forms.Label();
|
||||
this.textBoxAccountInfoSymbol = new System.Windows.Forms.TextBox();
|
||||
this.tabPage4 = new System.Windows.Forms.TabPage();
|
||||
this.comboBox12 = new System.Windows.Forms.ComboBox();
|
||||
this.button72 = new System.Windows.Forms.Button();
|
||||
this.button36 = new System.Windows.Forms.Button();
|
||||
this.comboBox10 = new System.Windows.Forms.ComboBox();
|
||||
this.comboBox9 = new System.Windows.Forms.ComboBox();
|
||||
@@ -182,6 +191,7 @@
|
||||
this.button14 = new System.Windows.Forms.Button();
|
||||
this.button13 = new System.Windows.Forms.Button();
|
||||
this.tabPage7 = new System.Windows.Forms.TabPage();
|
||||
this.button71 = new System.Windows.Forms.Button();
|
||||
this.button23 = new System.Windows.Forms.Button();
|
||||
this.iCustomBtn = new System.Windows.Forms.Button();
|
||||
this.tabPage8 = new System.Windows.Forms.TabPage();
|
||||
@@ -202,13 +212,7 @@
|
||||
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.button73 = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
@@ -1154,6 +1158,64 @@
|
||||
this.tabPage3.Text = "Account Information";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button70
|
||||
//
|
||||
this.button70.Location = new System.Drawing.Point(371, 292);
|
||||
this.button70.Name = "button70";
|
||||
this.button70.Size = new System.Drawing.Size(97, 23);
|
||||
this.button70.TabIndex = 18;
|
||||
this.button70.Text = "ChangeAccount";
|
||||
this.button70.UseVisualStyleBackColor = true;
|
||||
this.button70.Click += new System.EventHandler(this.button70_Click);
|
||||
//
|
||||
// label33
|
||||
//
|
||||
this.label33.AutoSize = true;
|
||||
this.label33.Location = new System.Drawing.Point(168, 269);
|
||||
this.label33.Name = "label33";
|
||||
this.label33.Size = new System.Drawing.Size(66, 13);
|
||||
this.label33.TabIndex = 17;
|
||||
this.label33.Text = "MT4 Server:";
|
||||
//
|
||||
// label32
|
||||
//
|
||||
this.label32.AutoSize = true;
|
||||
this.label32.Location = new System.Drawing.Point(168, 241);
|
||||
this.label32.Name = "label32";
|
||||
this.label32.Size = new System.Drawing.Size(56, 13);
|
||||
this.label32.TabIndex = 17;
|
||||
this.label32.Text = "Password:";
|
||||
//
|
||||
// label31
|
||||
//
|
||||
this.label31.AutoSize = true;
|
||||
this.label31.Location = new System.Drawing.Point(168, 214);
|
||||
this.label31.Name = "label31";
|
||||
this.label31.Size = new System.Drawing.Size(36, 13);
|
||||
this.label31.TabIndex = 17;
|
||||
this.label31.Text = "Login:";
|
||||
//
|
||||
// textBoxAccountHost
|
||||
//
|
||||
this.textBoxAccountHost.Location = new System.Drawing.Point(234, 266);
|
||||
this.textBoxAccountHost.Name = "textBoxAccountHost";
|
||||
this.textBoxAccountHost.Size = new System.Drawing.Size(238, 20);
|
||||
this.textBoxAccountHost.TabIndex = 17;
|
||||
//
|
||||
// textBoxAccountPassword
|
||||
//
|
||||
this.textBoxAccountPassword.Location = new System.Drawing.Point(234, 238);
|
||||
this.textBoxAccountPassword.Name = "textBoxAccountPassword";
|
||||
this.textBoxAccountPassword.Size = new System.Drawing.Size(238, 20);
|
||||
this.textBoxAccountPassword.TabIndex = 16;
|
||||
//
|
||||
// textBoxAccountLogin
|
||||
//
|
||||
this.textBoxAccountLogin.Location = new System.Drawing.Point(232, 212);
|
||||
this.textBoxAccountLogin.Name = "textBoxAccountLogin";
|
||||
this.textBoxAccountLogin.Size = new System.Drawing.Size(238, 20);
|
||||
this.textBoxAccountLogin.TabIndex = 15;
|
||||
//
|
||||
// button67
|
||||
//
|
||||
this.button67.Location = new System.Drawing.Point(157, 33);
|
||||
@@ -1368,6 +1430,8 @@
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.Controls.Add(this.comboBox12);
|
||||
this.tabPage4.Controls.Add(this.button72);
|
||||
this.tabPage4.Controls.Add(this.button36);
|
||||
this.tabPage4.Controls.Add(this.comboBox10);
|
||||
this.tabPage4.Controls.Add(this.comboBox9);
|
||||
@@ -1391,6 +1455,25 @@
|
||||
this.tabPage4.Text = "MarketInfo";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// comboBox12
|
||||
//
|
||||
this.comboBox12.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBox12.FormattingEnabled = true;
|
||||
this.comboBox12.Location = new System.Drawing.Point(13, 188);
|
||||
this.comboBox12.Name = "comboBox12";
|
||||
this.comboBox12.Size = new System.Drawing.Size(186, 21);
|
||||
this.comboBox12.TabIndex = 38;
|
||||
//
|
||||
// button72
|
||||
//
|
||||
this.button72.Location = new System.Drawing.Point(208, 186);
|
||||
this.button72.Name = "button72";
|
||||
this.button72.Size = new System.Drawing.Size(111, 23);
|
||||
this.button72.TabIndex = 37;
|
||||
this.button72.Text = "TerminalInfoString";
|
||||
this.button72.UseVisualStyleBackColor = true;
|
||||
this.button72.Click += new System.EventHandler(this.button72_Click);
|
||||
//
|
||||
// button36
|
||||
//
|
||||
this.button36.Location = new System.Drawing.Point(208, 157);
|
||||
@@ -1785,6 +1868,7 @@
|
||||
//
|
||||
// tabPage6
|
||||
//
|
||||
this.tabPage6.Controls.Add(this.button73);
|
||||
this.tabPage6.Controls.Add(this.textBoxPrint);
|
||||
this.tabPage6.Controls.Add(this.button27);
|
||||
this.tabPage6.Controls.Add(this.button14);
|
||||
@@ -1799,14 +1883,14 @@
|
||||
//
|
||||
// textBoxPrint
|
||||
//
|
||||
this.textBoxPrint.Location = new System.Drawing.Point(13, 86);
|
||||
this.textBoxPrint.Location = new System.Drawing.Point(13, 108);
|
||||
this.textBoxPrint.Name = "textBoxPrint";
|
||||
this.textBoxPrint.Size = new System.Drawing.Size(386, 20);
|
||||
this.textBoxPrint.TabIndex = 3;
|
||||
//
|
||||
// button27
|
||||
//
|
||||
this.button27.Location = new System.Drawing.Point(405, 84);
|
||||
this.button27.Location = new System.Drawing.Point(405, 106);
|
||||
this.button27.Name = "button27";
|
||||
this.button27.Size = new System.Drawing.Size(75, 23);
|
||||
this.button27.TabIndex = 2;
|
||||
@@ -1836,6 +1920,7 @@
|
||||
//
|
||||
// tabPage7
|
||||
//
|
||||
this.tabPage7.Controls.Add(this.button71);
|
||||
this.tabPage7.Controls.Add(this.button23);
|
||||
this.tabPage7.Controls.Add(this.iCustomBtn);
|
||||
this.tabPage7.Location = new System.Drawing.Point(4, 40);
|
||||
@@ -1846,6 +1931,16 @@
|
||||
this.tabPage7.Text = "Technical Indicators";
|
||||
this.tabPage7.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button71
|
||||
//
|
||||
this.button71.Location = new System.Drawing.Point(6, 64);
|
||||
this.button71.Name = "button71";
|
||||
this.button71.Size = new System.Drawing.Size(107, 23);
|
||||
this.button71.TabIndex = 17;
|
||||
this.button71.Text = "iBarShift";
|
||||
this.button71.UseVisualStyleBackColor = true;
|
||||
this.button71.Click += new System.EventHandler(this.button71_Click);
|
||||
//
|
||||
// button23
|
||||
//
|
||||
this.button23.Location = new System.Drawing.Point(6, 35);
|
||||
@@ -2076,63 +2171,15 @@
|
||||
this.button69.UseVisualStyleBackColor = true;
|
||||
this.button69.Click += new System.EventHandler(this.button69_Click);
|
||||
//
|
||||
// textBoxAccountLogin
|
||||
// button73
|
||||
//
|
||||
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);
|
||||
this.button73.Location = new System.Drawing.Point(13, 74);
|
||||
this.button73.Name = "button73";
|
||||
this.button73.Size = new System.Drawing.Size(75, 23);
|
||||
this.button73.TabIndex = 4;
|
||||
this.button73.Text = "TimeGMT";
|
||||
this.button73.UseVisualStyleBackColor = true;
|
||||
this.button73.Click += new System.EventHandler(this.button73_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
@@ -2366,6 +2413,10 @@
|
||||
private System.Windows.Forms.TextBox textBoxAccountPassword;
|
||||
private System.Windows.Forms.TextBox textBoxAccountLogin;
|
||||
private System.Windows.Forms.Button button70;
|
||||
private System.Windows.Forms.Button button71;
|
||||
private System.Windows.Forms.ComboBox comboBox12;
|
||||
private System.Windows.Forms.Button button72;
|
||||
private System.Windows.Forms.Button button73;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace TestApiClientUI
|
||||
comboBox9.DataSource = Enum.GetNames(typeof(EnumTerminalInfoInteger));
|
||||
comboBox10.DataSource = Enum.GetNames(typeof(EnumTerminalInfoDouble));
|
||||
comboBox11.DataSource = Enum.GetNames(typeof(EnumObject));
|
||||
comboBox12.DataSource = Enum.GetNames(typeof(ENUM_TERMINAL_INFO_STRING));
|
||||
comboBoxAccountInfoCmd.DataSource = Enum.GetNames(typeof(TradeOperation));
|
||||
|
||||
_apiClient.QuoteUpdated += apiClient_QuoteUpdated;
|
||||
@@ -615,18 +616,28 @@ namespace TestApiClientUI
|
||||
listBoxProceHistory.DataSource = items;
|
||||
}
|
||||
|
||||
//TimeCurrent
|
||||
private void button13_Click(object sender, EventArgs e)
|
||||
{
|
||||
var retVal = _apiClient.TimeCurrent();
|
||||
PrintLog($"TimeCurrent result: {retVal}");
|
||||
}
|
||||
|
||||
//TimeLocal
|
||||
private void button14_Click(object sender, EventArgs e)
|
||||
{
|
||||
var retVal = _apiClient.TimeLocal();
|
||||
PrintLog($"TimeLocal result: {retVal}");
|
||||
}
|
||||
|
||||
//TimeGMT
|
||||
private void button73_Click(object sender, EventArgs e)
|
||||
{
|
||||
var retVal = _apiClient.TimeGMT();
|
||||
PrintLog($"TimeGMT result: {retVal}");
|
||||
}
|
||||
|
||||
//RefreshRates
|
||||
private void buttonRefreshRates_Click(object sender, EventArgs e)
|
||||
{
|
||||
var retVal = _apiClient.RefreshRates();
|
||||
@@ -1129,6 +1140,16 @@ namespace TestApiClientUI
|
||||
PrintLog($"TerminalInfoDouble: result = {result}");
|
||||
}
|
||||
|
||||
//TerminalInfoString
|
||||
private async void button72_Click(object sender, EventArgs e)
|
||||
{
|
||||
ENUM_TERMINAL_INFO_STRING propId;
|
||||
Enum.TryParse(comboBox12.Text, out propId);
|
||||
|
||||
var result = await Execute(() => _apiClient.TerminalInfoString(propId));
|
||||
PrintLog($"TerminalInfoString: result = {result}");
|
||||
}
|
||||
|
||||
private void checkBox2_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
var checkbox = sender as CheckBox;
|
||||
@@ -1462,5 +1483,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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2209
-27
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user