Click or drag to resize

Greater Less

IsGreater/IsLess predicates generate a signal if a value of series is greater(or less) than a given number at the current moment.

Implementation and Usage

These predicates can be used in a strategy with the following constructors:

IsGreater

IsLess

creates new instance of the IsGreater / IsLess predicate with default zero value.

IsGreater(Double)

IsLess(Double)

creates new instance of the IsGreater / IsLess predicate with the given value to compare.

The value of the indicators is updated by simple prototype of method Add():

Add(Double)

Add(Double, DateTime)

Use

Greater

Less

properties to get the current value.

Example

The example of IsGreater predicate for Apple Inc. stock price(Bar close price) with level of 235.5.

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

Greater Less 001