Dropped Gained |
IsDropped (IsGained) predicate generates a signal when the price has fallen(risen) by a specified percent during a certain period.
These predicates can be used in a strategy with the following constructors:
creates new instance of the IsDropped / IsGained predicate with default period equal to 14 and drop value equal to 1.0%.
creates new instance of the IsDropped / IsGained predicate with point window.
creates new instance of the IsDropped / IsGained predicate with time window.
The value of the indicators is updated by simple prototype of method Add():
Use
properties to get the current value.
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).
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}