Overall Statistics |
Total Trades 3629 Average Win 0.65% Average Loss -0.70% Compounding Annual Return 10.846% Drawdown 21.300% Expectancy 0.065 Net Profit 110.333% Sharpe Ratio 0.757 Loss Rate 45% Win Rate 55% Profit-Loss Ratio 0.92 Alpha -0.016 Beta 0.96 Annual Standard Deviation 0.15 Annual Variance 0.023 Information Ratio -0.597 Tracking Error 0.036 Treynor Ratio 0.118 Total Fees $17043.15 |
namespace QuantConnect { public class DICrossAlgorithm : QCAlgorithm { private decimal _tolerance = .02m; private AverageDirectionalIndex _adx; public override void Initialize() { SetStartDate(2010, 1, 1); AddEquity("SPY", Resolution.Minute); _adx = ADX("SPY", 14*8, Resolution.Hour); } public override void OnData(Slice data) { var diplus = _adx.PositiveDirectionalIndex; var diminus = _adx.NegativeDirectionalIndex; if (!Portfolio.HoldStock) { if (diplus > diminus * (1 + _tolerance)) { SetHoldings("SPY", 1); } if (diplus < diminus * (1 - _tolerance)) { SetHoldings("SPY", -1); } } } public override void OnEndOfDay() { Liquidate(); } } }