Пример #1
0
 /// <summary>
 /// Construct indicators for display
 /// </summary>
 /// <returns></returns>
 string[] GetDisplayIndicators()
 {
     string[] indicators = new string[] {
         _time.ToString(),
              _EMA.GetSignal().ToString("F5", System.Globalization.CultureInfo.InvariantCulture),
         (_ATR.GetSignal() * 1000).ToString("F5", System.Globalization.CultureInfo.InvariantCulture),
         _lastBar.Close.ToString("F5", System.Globalization.CultureInfo.InvariantCulture)
     };
     return(indicators);
 }
Пример #2
0
        /// <summary>
        /// Compute ATR indicator
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        decimal ComputeATR(Bar lastBar, decimal currentSMA)
        {
            decimal ATR = decimal.MinValue;

            // calculate the ATR using closing prices for so many bars back
            if (UseATRFromATSGlobalIndicator)
            {
                _ATRFromATSGlobalIndicator.UpdateValue(lastBar.High, lastBar.Low, lastBar.Close, currentSMA);
                ATR = _ATRFromATSGlobalIndicator.GetSignal();
            }
            else
            {
                //SMA = Calc.Avg(Calc.EndSlice(_blt[symbol].Open(), _barsback));
            }
            // this way we can debug our indicators during development
            // indicators are sent in the same order as they are named above
            return(ATR);
        }