Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
233.365%
Drawdown
2.200%
Expectancy
0
Net Profit
0%
Sharpe Ratio
4.085
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.061
Beta
1.005
Annual Standard Deviation
0.194
Annual Variance
0.038
Information Ratio
-7.311
Tracking Error
0.008
Treynor Ratio
0.788
Total Fees
$3.17
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

namespace QuantConnect.Algorithm.CSharp
{
    /// <summary>
    /// Using indicators based on Heikin Ashi candles
    /// </summary>
    public class HeikinAshiIndicators : QCAlgorithm
    {
        private Symbol _spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
        private RelativeStrengthIndex _rsi;
        private AverageDirectionalIndex _adx;

        public override void Initialize()
        {
            SetStartDate(2013, 10, 07);  //Set Start Date
            SetEndDate(2013, 10, 11);    //Set End Date
            SetCash(100000);             //Set Strategy Cash
            // Find more symbols here: http://quantconnect.com/data
            AddEquity("SPY", Resolution.Minute);

            var heikinAshi = HeikinAshi(_spy, Resolution.Minute);
            _rsi = new RelativeStrengthIndex("HA_RSI", 14);
            _adx = new AverageDirectionalIndex("HA_ADX", 14);

            heikinAshi.Updated += (sender, consolidated) =>
            {
                if (heikinAshi.IsReady)
                {
                    var tradeBar = new TradeBar(heikinAshi.Current.EndTime, _spy, heikinAshi.Open, heikinAshi.High, heikinAshi.Low, heikinAshi.Close, 0);
                    _rsi.Update(consolidated);
                    _adx.Update(tradeBar);
                }
            };           
        }

        public override void OnData(Slice data)
        {
            if (!_adx.IsReady || !_rsi.IsReady) return;

            Log("ADX: " + _adx + " RSI: " + _rsi);

            if (!Portfolio.Invested)
            {
                SetHoldings(_spy, 1);
                Debug("Purchased Stock");
            }
        }
    }
}