Exemplo n.º 1
0
 /// <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;
         }
     }
 }