Click or drag to resize

Time

IsTime predicate generates a signal if the current time value(during testing) satisfies the specified condition. For example, the signal will be generated if the given condition is “CurrentTime is greater or equal 15:45:00” and the current time has exceeded 15:45:00.

Implementation and Usage

This predicate can be used in a strategy with the following constructors:

IsTime - Creates new instance of the IsTime predicate with default condition “CurrentTime is equal 09:30:00”.

IsTime(TimeSpan, IsTimeComparisonOperator) - Creates new instance of public the IsTime predicate with the given values for time and comparison operator.

The value of the indicator is updated by time prototype of method Add():

Add(DateTime)

Use

Result - property to get the current value.

Example

IsTime predicate for Apple Inc. stock price(Bar close price). The signal is generated when CurrentTime is greater or equal to 11:00:00:

C#
 1public partial class InstrumentExecutor : InstrumentExecutorBase
 2{
 3-    #region LocalVariables
 4 
 5     //Is Time indicator
 6     IsTime isTime;
 7     //chart line
 8     Line isTimeLine;
 9 
10     #endregion
11
12-    #region Events
13     public override void OnInit()
14     {
15         //init indicator
16         isTime = new IsTime(new TimeSpan(11, 0, 0) , IsTime.ComparisonOperator.GreaterOrEqual);
17 
18         //init line
19         isTimeLine = Charting.CreateLine("IsTime", "", Symbol, Pens.Black, LineStyle.Line, Charting.PriceChart, 2);
20     }
21 
22     public override void OnBarClose()
23     {
24         //update value of the indicator
25         isTime.Add(CurrentTime);
26         //chart
27         isTimeLine.Draw(CurrentTime,isTime.Result);
28     }
29     #endregion
30}
Chart

Time 001