Click or drag to resize

Increasing Decreasing

IsIncreasing (IsDecreasing) predicate receives a single input line, and generates a signal, if during the given period the series values are increasing(decreasing). The smallest value of the period for this predicate equals 2.

Implementation and Usage

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

IsIncreasing

IsDecreasing

creates new instance of the IsIncreasing / IsDecreasing  predicate with default period equal to 14.

IsIncreasing(Int32)

IsDecreasing(Int32)

creates new instance of the IsIncreasing / IsDecreasing predicate with point window.

IsIncreasing(TimeSpan)

IsDecreasing(TimeSpan)

creates new instance of the IsIncreasing / IsDecreasing predicate with time window.

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

Add(Double)

Add(Double, DateTime)

Use

Increasing

Decreasing

properties to get the current value.

Example

The example of IsIncreasing predicate implementation with period of 5 for Apple Inc. stock price(Bar close price):

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

Increasing Decreasing 001