mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-19 13:48:11 +00:00
Issue #122: Implemented UnlockTicks function in MtApi (MT5)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
{
|
||||
OnTradeTransaction = 1,
|
||||
OnBookEvent = 2,
|
||||
OnTick = 3
|
||||
OnTick = 3,
|
||||
OnLastTimeBar = 4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MtApi5.Events
|
||||
{
|
||||
public class OnLastTimeBarEvent
|
||||
{
|
||||
public MqlRates Rates { get; set; }
|
||||
public string Instrument { get; set; }
|
||||
public int ExpertHandle { get; set; }
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -7,7 +7,6 @@ namespace MtApi5
|
||||
{
|
||||
public MqlRates(DateTime time, double open, double high, double low, double close, long tick_volume, int spread, long real_volume)
|
||||
{
|
||||
this.time = time;
|
||||
mt_time = Mt5TimeConverter.ConvertToMtTime(time);
|
||||
this.open = open;
|
||||
this.high = high;
|
||||
@@ -20,7 +19,6 @@ namespace MtApi5
|
||||
|
||||
internal MqlRates(long time, double open, double high, double low, double close, long tick_volume, int spread, long real_volume)
|
||||
{
|
||||
this.time = Mt5TimeConverter.ConvertFromMtTime(time);
|
||||
mt_time = time;
|
||||
this.open = open;
|
||||
this.high = high;
|
||||
@@ -35,7 +33,7 @@ namespace MtApi5
|
||||
{
|
||||
}
|
||||
|
||||
public DateTime time { get; set; } // Period start time
|
||||
public DateTime time => Mt5TimeConverter.ConvertFromMtTime(mt_time); // Period start time
|
||||
public long mt_time { get; set; } // Period start time (original MT time)
|
||||
public double open { get; set; } // Open price
|
||||
public double high { get; set; } // The highest price of the period
|
||||
|
||||
@@ -248,6 +248,8 @@ namespace MtApi5
|
||||
GlobalVariableTemp = 154,
|
||||
GlobalVariableSetOnCondition = 156,
|
||||
GlobalVariablesDeleteAll = 157,
|
||||
GlobalVariablesTotal = 158
|
||||
GlobalVariablesTotal = 158,
|
||||
|
||||
UnlockTicks = 159
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5TimeBarArgs: EventArgs
|
||||
{
|
||||
internal Mt5TimeBarArgs(int expertHandle, string symbol, MqlRates rates)
|
||||
{
|
||||
ExpertHandle = expertHandle;
|
||||
Rates = rates;
|
||||
Symbol = symbol;
|
||||
}
|
||||
|
||||
public int ExpertHandle { get; }
|
||||
public string Symbol { get; }
|
||||
public MqlRates Rates { get; }
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,10 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="CopyTicksFlag.cs" />
|
||||
<Compile Include="Events\OnBookEvent.cs" />
|
||||
<Compile Include="Events\OnLastTimeBarEvent.cs" />
|
||||
<Compile Include="Events\OnTickEvent.cs" />
|
||||
<Compile Include="Events\OnTradeTransactionEvent.cs" />
|
||||
<Compile Include="Mt5TimeBarArgs.cs" />
|
||||
<Compile Include="MqlBookInfo.cs" />
|
||||
<Compile Include="MqlParam.cs" />
|
||||
<Compile Include="MqlRates.cs" />
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace MtApi5
|
||||
_mtEventHandlers[Mt5EventTypes.OnBookEvent] = ReceivedOnBookEvent;
|
||||
_mtEventHandlers[Mt5EventTypes.OnTick] = ReceivedOnTickEvent;
|
||||
_mtEventHandlers[Mt5EventTypes.OnTradeTransaction] = ReceivedOnTradeTransaction;
|
||||
_mtEventHandlers[Mt5EventTypes.OnLastTimeBar] = ReceivedOnLastTimeBar;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -3057,6 +3058,18 @@ namespace MtApi5
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Backtesting functions
|
||||
|
||||
///<summary>
|
||||
///The function unlock ticks in backtesting mode.
|
||||
///</summary>
|
||||
public void UnlockTicks()
|
||||
{
|
||||
SendCommand<object>(Mt5CommandType.UnlockTicks, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Public Methods
|
||||
|
||||
#region Properties
|
||||
@@ -3104,6 +3117,7 @@ namespace MtApi5
|
||||
public event EventHandler<Mt5ConnectionEventArgs> ConnectionStateChanged;
|
||||
public event EventHandler<Mt5TradeTransactionEventArgs> OnTradeTransaction;
|
||||
public event EventHandler<Mt5BookEventArgs> OnBookEvent;
|
||||
public event EventHandler<Mt5TimeBarArgs> OnLastTimeBar;
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
@@ -3216,6 +3230,12 @@ namespace MtApi5
|
||||
QuoteUpdate?.Invoke(this, new Mt5QuoteEventArgs(quote));
|
||||
}
|
||||
|
||||
private void ReceivedOnLastTimeBar(int expertHandler, string payload)
|
||||
{
|
||||
var e = JsonConvert.DeserializeObject<OnLastTimeBarEvent>(payload);
|
||||
OnLastTimeBar?.Invoke(this, new Mt5TimeBarArgs(expertHandler, e.Instrument, e.Rates));
|
||||
}
|
||||
|
||||
private void Connect(string host, int port)
|
||||
{
|
||||
var client = new MtClient(host, port);
|
||||
|
||||
Reference in New Issue
Block a user