mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 19:17:48 +00:00
57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
|
|
namespace MtApi.Monitors
|
|
{
|
|
public class TimeframeTradeMonitor : TradeMonitor
|
|
{
|
|
#region Fields
|
|
private volatile bool _isStarted;
|
|
#endregion
|
|
|
|
#region ctor
|
|
public TimeframeTradeMonitor(MtApiClient apiClient)
|
|
: base(apiClient)
|
|
{
|
|
apiClient.OnLastTimeBar += ApiClient_OnLastTimeBar;
|
|
}
|
|
#endregion
|
|
|
|
#region Public Methods
|
|
//
|
|
// Summary:
|
|
// Gets a value indicating whether the TimeframeTradeMonitor should raise checking orders
|
|
//
|
|
// Returns:
|
|
// true if PositionMonitor should check orders
|
|
// otherwise, false.
|
|
public override bool IsStarted => _isStarted;
|
|
|
|
#endregion
|
|
|
|
#region Protected Methods
|
|
protected override void OnMtConnected() {}
|
|
|
|
protected override void OnMtDisconnected() {}
|
|
|
|
protected override void OnStart()
|
|
{
|
|
_isStarted = true;
|
|
}
|
|
|
|
protected override void OnStop()
|
|
{
|
|
_isStarted = false;
|
|
}
|
|
#endregion
|
|
|
|
#region Private Methods
|
|
private void ApiClient_OnLastTimeBar(object sender, TimeBarArgs e)
|
|
{
|
|
if (_isStarted)
|
|
{
|
|
Check();
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|