示例#1
0
        /// <summary>
        /// This constructs a default indicator. This is most useful for
        /// putting indicator logic directly into your strategy.
        /// </summary>
        /// <returns></returns>
        public IndicatorCommon Indicator()
        {
            IndicatorCommon indicator = new IndicatorCommon();

            model.AddDependency(indicator);
            return(indicator);
        }
示例#2
0
        public override void OnInitialize()
        {
            Name              = "IFT";
            Drawing.PaneType  = PaneType.Secondary;
            Drawing.IsVisible = true;

            value1 = Formula.Indicator();
            value2 = Formula.Indicator();
            rsi    = Formula.RSI(Input, period);
            wma    = Formula.WMA(value1, period);
            Formula.Line(0.5, Color.LightGreen);
            Formula.Line(-0.5, Color.Red);
        }
示例#3
0
        public override void OnInitialize()
        {
            Drawing.PaneType  = PaneType.Secondary;
            Drawing.GraphType = GraphType.Histogram;
            Drawing.GroupName = "Volume";

            averageVolume = new SMA(Bars.Volume, 5);
            averageVolume.Drawing.GroupName = "Volume";
            AddIndicator(averageVolume);

            high    = Formula.Line(266000, Color.Red);
            average = Formula.Line(187000, Color.Orange);
            low     = Formula.Line(107000, Color.Green);
        }
示例#4
0
        public IndicatorCommon Line(double value, Color color, string name)
        {
            IndicatorCommon line;

            line = new IndicatorCommon();
            line.Drawing.IsVisible = true;
            line.Drawing.PaneType  = model.Drawing.PaneType;
            line.Drawing.Color     = Color.Green;
            line.Drawing.GroupName = model.Drawing.GroupName;
            line.Name       = name;
            line.StartValue = value;
            model.AddIndicator(line);
            return(line);
        }
示例#5
0
        public override void OnInitialize()
        {
            Name = "IFT";
            // Display below the price chart
            Drawing.PaneType = PaneType.Secondary;
            // Display below the price chart
            Drawing.IsVisible = true;

            // Creates the
            value1 = Formula.Indicator();
            value2 = Formula.Indicator();
            rsi    = Formula.RSI(Bars.Close, 5);
            wma    = Formula.WMA(value1, 5);
            Formula.Line(0.5, Color.LightGreen);
            Formula.Line(-0.5, Color.Red);
        }
示例#6
0
        public ADX(int period)
        {
            Drawing.Color     = Color.Green;
            Drawing.PaneType  = PaneType.Secondary;
            Drawing.IsVisible = true;
            Drawing.GroupName = "ADX";
            Drawing.GraphType = GraphType.Line;

            dmPlus      = Formula.Indicator();
            dmMinus     = Formula.Indicator();
            sumDmPlus   = Formula.Indicator();
            sumDmMinus  = Formula.Indicator();
            sumTr       = Formula.Indicator();
            tr          = Formula.Indicator();
            this.period = period;
        }
示例#7
0
        public override void OnInitialize()
        {
            Name              = "Wilder's RSI";
            Drawing.Color     = Color.Black;
            Drawing.PaneType  = PaneType.Secondary;
            Drawing.IsVisible = true;
            Formula.Line(70, Color.Red);
            Formula.Line(30, Color.Green);
            Drawing.ScaleMax = 100;
            Drawing.ScaleMin = 0;

            mom     = Formula.Indicator();
            gain    = Formula.Indicator();
            loss    = Formula.Indicator();
            avgGain = Formula.Indicator();
            avgLoss = Formula.Indicator();
        }
示例#8
0
 public void AddIndicator(IndicatorCommon indicator)
 {
     indicator.IsActive = isActive;
     if (chain.Dependencies.Contains(indicator.Chain))
     {
         throw new ApplicationException("Indicator " + indicator.Name + " already added.");
     }
     if (this is Strategy)
     {
         Strategy strategy = this as Strategy;
         indicator.Performance = strategy.Performance;
     }
     else if (this is IndicatorCommon)
     {
         IndicatorCommon thisIndicator = this as IndicatorCommon;
         indicator.Performance = thisIndicator.Performance;
     }
     else if (this is Portfolio)
     {
         Portfolio thisPortfolio = this as Portfolio;
         indicator.Performance = thisPortfolio.Performance;
     }
     else
     {
         indicator.Performance = new Performance(this);
     }
     // Apply Properties from project.xml, if any.
     if (properties != null)
     {
         string[] keys = properties.GetModelKeys();
         for (int i = 0; i < keys.Length; i++)
         {
             ModelProperties indicatorProperties = properties.GetModel(keys[i]);
             if (indicator.name.Equals(indicatorProperties.Name) &&
                 indicatorProperties.ModelType == ModelType.Indicator)
             {
                 indicator.OnProperties(indicatorProperties);
                 break;
             }
         }
     }
     chain.Dependencies.Add(indicator.Chain);
 }