Click or drag to resize

New High New Low

IsNewHigh / IsNewLow predicate generates a signal if a maximum(minimum) of the input series for a defined short period stays actual for the specified long period. For example, if the short time period is set to 5, and the long is 10, the signal will be generated if the maximum(minimum) of the last 10 values was reached at one of the last 5 values.

Implementation and Usage

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

IsNewHigh

IsNewLow

creates new instance of the IsNewHigh / IsNewLow  predicate with default short period equal to 14 and long period equal to 28.

IsNewHigh(Int32, Int32)

IsNewLow(Int32, Int32)

creates new instance of the IsNewHigh / IsNewLow predicate with point windows.

IsNewHigh(TimeSpan, TimeSpan)

IsNewLow(TimeSpan, TimeSpan)

creates new instance of the IsNewHigh / IsNewLow predicate with time windows.

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

Add(Double)

Add(Double, DateTime)

Use

NewHigh

NewLow

properties to get the current value.

Example

The example of IsNewHigh predicate with periods of 5 and 15 for Apple Inc. stock price(Bar close price).

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

New High New Low 001