Constant |
Constant returns a constant value.
To implement constant in a strategy use the following constructors:
Constant – sets the default value equal to 7 as a constant value.
Constant(Double) – creates constant with given fixed value.
This indicator supports simple prototype of method Add():
But the value of this indicator is not updated so there is no reason to use method Add() as it does not change the initial value. Use Result property to get the constant value.
Example
1public partial class InstrumentExecutor : InstrumentExecutorBase 2{ 3- #region LocalVariables 4 5 //Constant indicator 6 Constant constant; 7 //Constant chart line 8 Line constantLine; 9 10 #endregion 11 12- #region Events 13 public override void OnInit() 14 { 15 //init Constant indicator 16 constant = new Constant(250); 17 18 //init Constant line 19 constantLine = Charting.CreateLine("Constant", "", Symbol, Pens.Black, LineStyle.Line, Charting.PriceChart, 1); 20 } 21 public override void OnBarClose() 22 { 23 //get indicator statistic and draw on chart 24 constantLine.Draw(CurrentTime, constant.Result); 25 } 26 27 #endregion 28}