2024-06-16 13:57:50 +03:00
using MtApi.Monitors.Triggers ;
2016-09-09 19:10:10 +03:00
namespace MtApi.Monitors
{
public class TimerTradeMonitor : TradeMonitor
{
2020-10-13 15:52:55 +02:00
#region Fields
2020-10-13 15:10:26 +02:00
private readonly TimeElapsedTrigger _timeElapsedTrigger ;
2020-10-13 15:52:55 +02:00
#endregion
#region Properties
/// <summary>
/// Interval for raising the trigger
/// </summary>
2016-09-09 19:10:10 +03:00
public double Interval
{
2020-10-13 15:10:26 +02:00
get => _timeElapsedTrigger . Interval . TotalMilliseconds ;
set => _timeElapsedTrigger . Interval = TimeSpan . FromMilliseconds ( value );
2016-09-09 19:10:10 +03:00
}
2020-10-13 15:52:55 +02:00
#endregion
2016-09-09 19:10:10 +03:00
2020-10-13 15:52:55 +02:00
#region ctors
/// <summary>
/// Constructor for initializing a new instance with a default <see cref="Interval"/> of 10 seconds.
/// <para>SyncTrigger is set to true by default</para>
/// </summary>
/// <param name="apiClient">The <see cref="MtApiClient"/> which will be used to communicate with MetaTrader.</param>
2020-10-13 15:10:26 +02:00
public TimerTradeMonitor ( MtApiClient apiClient )
: this ( apiClient , new TimeElapsedTrigger ( TimeSpan . FromSeconds ( 10 )))
2016-09-09 19:10:10 +03:00
{
2020-10-13 15:36:59 +02:00
SyncTrigger = true ; //Sync-Trigger set to true, to have the same behavior as before
2016-09-09 19:10:10 +03:00
}
2020-10-13 15:52:55 +02:00
/// <summary>
/// Constructor for initializing a new instance with a custom instance of <see cref="TimeElapsedTrigger"/>.
/// <para>SyncTrigger is set to false by default</para>
/// </summary>
/// <param name="apiClient">The <see cref="MtApiClient"/> which will be used to communicate with MetaTrader.</param>
/// <param name="timeElapsedTrigger">The custom instance of <see cref="TimeElapsedTrigger"/> which will be used to trigger this instance of <see cref="TradeMonitor"/>.</param>
2020-10-13 15:10:26 +02:00
public TimerTradeMonitor ( MtApiClient apiClient , TimeElapsedTrigger timeElapsedTrigger )
: base ( apiClient , timeElapsedTrigger )
2016-09-09 19:10:10 +03:00
{
2020-10-13 15:10:26 +02:00
_timeElapsedTrigger = timeElapsedTrigger ;
2016-09-09 19:10:10 +03:00
}
2020-10-13 15:52:55 +02:00
#endregion
2016-09-09 19:10:10 +03:00
}
2020-10-13 15:10:26 +02:00
}