Example #1
0
 /// <summary>Adds TechnicalData object to the indicator</summary>
 /// <param name="data">TechnicalData object to be added</param>
 public virtual void AddData(MarketSage.Library.TechnicalData data, ref Account account)
 {
     _account = account;
     if (!_ready)
     {
         _data.Add(data);
         if (_data.Count >= _period)
         {
             _ready = true;
             GenerateSignal();
         }
     }
     else
     {
         _data.RemoveAt(0);
         _data.Add(data);
         GenerateSignal();
     }
 }
 /// <summary>
 /// Adds TechnicalData object to the indicator
 /// </summary>
 /// <param name="data">TechnicalData</param>
 public void AddData(MarketSage.Library.TechnicalData data)
 {
     if (!_ready)
     {
         int count = 0;
         for (int i = 0; i < _indicators.Count; i++)
         {
             IIndicator indicator = (IIndicator)_indicators[i];
             indicator.AddData(data);
             if (indicator.IsReady())
             {
                 count++;
             }
         }
         if (count == _indicators.Count)
         {
             _ready    = true;
             _voteBuy  = 0;
             _voteSell = 0;
             _voteHold = 0;
             for (int i = 0; i < _indicators.Count; i++)
             {
                 IIndicator indicator = (IIndicator)_indicators[i];
                 if (indicator.IsBuy())
                 {
                     _voteBuy++;
                 }
                 if (indicator.IsSell())
                 {
                     _voteSell++;
                 }
                 if (indicator.IsHold())
                 {
                     _voteHold++;
                 }
             }
             if ((_voteBuy > _voteSell) && (_voteBuy > _voteHold))
             {
                 _direction = 1;
             }
             else
             if ((_voteSell > _voteBuy) && (_voteSell > _voteHold))
             {
                 _direction = -1;
             }
             else
             {
                 _direction = 0;
             }
         }
     }
     else
     {
         _voteBuy  = 0;
         _voteSell = 0;
         _voteHold = 0;
         for (int i = 0; i < _indicators.Count; i++)
         {
             IIndicator indicator = (IIndicator)_indicators[i];
             indicator.AddData(data);
             if (indicator.IsBuy())
             {
                 _voteBuy++;
             }
             if (indicator.IsSell())
             {
                 _voteSell++;
             }
             if (indicator.IsHold())
             {
                 _voteHold++;
             }
         }
         if ((_voteBuy > _voteSell) && (_voteBuy > _voteHold))
         {
             _direction = 1;
         }
         else
         if ((_voteSell > _voteBuy) && (_voteSell > _voteHold))
         {
             _direction = -1;
         }
         else
         {
             _direction = 0;
         }
     }
 }