Beispiel #1
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);
 }