Click or drag to resize

Dropped Gained

IsDropped (IsGained) predicate generates a signal when the price has fallen(risen) by a specified percent during a certain period.

Implementation and Usage

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

IsDropped

IsGained

creates new instance of the IsDropped / IsGained  predicate with default period equal to 14 and drop value equal to 1.0%.

IsDropped(Int32, Double)

IsGained(Int32, Double)

creates new instance of the IsDropped / IsGained predicate with point window.

IsDropped(TimeSpan, Double)

IsGained(TimeSpan, Double)

creates new instance of the IsDropped / IsGained predicate with time window.

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

Add(Double)

Add(Double, DateTime)

Use

Dropped

Gained

properties to get the current value.

Example

The example of IsDropped predicate with period of 30 and level of decrease(increase) equal to 0.5% for Apple Inc. stock price(Bar close price).

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

Droppet Gained 001