Exemplo n.º 1
0
        /// <summary>
        /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
        /// </summary>
        /// <seealso cref="QCAlgorithm.SetStartDate(System.DateTime)"/>
        /// <seealso cref="QCAlgorithm.SetEndDate(System.DateTime)"/>
        /// <seealso cref="QCAlgorithm.SetCash(decimal)"/>
        public override void Initialize()
        {
            //            mylog.Debug(",CurrentBar,Time,Price,smooth,low,i1,cycle0,cycle1,cycle2,fish,medianDelta,DC,instaperiod, v2,DCPeriod,realpart,imagpart,dcphase");
            mylog.Debug(ondataheader);
            //mylog.Debug(",Time,CurrentBar,Direction,TradeProfit,,Price,Profit,HoldingCost,FillQty,Fees,TransAmt");
            //mylog.Debug(transheader);
            //Initialize
            SetStartDate(2015, 05, 12);
            SetEndDate(2015, 05, 12);
            SetCash(25000);

            //Add as many securities as you like. All the data will be passed into the event handler:
            AddSecurity(SecurityType.Equity, _symbol, Resolution.Minute);

            _indicators = new AlgoIndicators
            {
                //BB = BB(_symbol, 20, 1, MovingAverageType.Simple, Resolution.Daily),
                RSI = RSI(_symbol, 14, MovingAverageType.Simple, Resolution.Daily),
                //ATR = ATR(_symbol, 14, MovingAverageType.Simple, Resolution.Daily),
                //EMA = EMA(_symbol, 14, Resolution.Daily),
                //SMA = SMA(_symbol, 14, Resolution.Daily),
                MACD = MACD(_symbol, 12, 26, 9, MovingAverageType.Simple, Resolution.Minute)
                //AROON = AROON(_symbol, 20, Resolution.Daily),
                //MOM = MOM(_symbol, 20, Resolution.Daily),
                //MOMP = MOMP(_symbol, 20, Resolution.Daily),
                //STD = STD(_symbol, 20, Resolution.Daily),
                //MIN = MIN(_symbol, 14, Resolution.Daily), // by default if the symbol is a tradebar type then it will be the min of the low property
                //MAX = MAX(_symbol, 14, Resolution.Daily),  // by default if the symbol is a tradebar type then it will be the max of the high property

                //open = new WindowIndicator<IndicatorDataPoint>(4)
                //Ft = FT(_symbol, samplesize, Resolution.Minute),
                //Rvi = RVI(_symbol, samplesize, Resolution.Minute)

            };
            //open = new RollingWindow<IndicatorDataPoint>(samplesize);
            //close = new RollingWindow<IndicatorDataPoint>(samplesize);
            //high = new RollingWindow<IndicatorDataPoint>(samplesize);
            //low = new RollingWindow<IndicatorDataPoint>(samplesize);
            //i1 = new RollingWindow<IndicatorDataPoint>(samplesize);
            //instperiod = new RollingWindow<IndicatorDataPoint>(samplesize);
            //v2 = new RollingWindow<IndicatorDataPoint>(samplesize);
            //v1 = new RollingWindow<IndicatorDataPoint>(samplesize);
            //Rvi = new RollingWindow<IndicatorDataPoint>(samplesize);
            unrealized = new RollingWindow<IndicatorDataPoint>(samplesize);
            iFishes = new RollingWindow<IndicatorDataPoint>(samplesize);
            RsiHistory = new RollingWindow<IndicatorDataPoint>(samplesize);
            //Signal = new RollingWindow<IndicatorDataPoint>(samplesize);
            //maxRvi = new Maximum("RVI_Max", samplesize);
            //minRvi = new Minimum("RVi_Min", samplesize);
            //maxSignal = new Maximum("Sig_Max", samplesize);
            //minSignal = new Minimum("Sig_Min", samplesize);
            fish = new FisherTransform(samplesize);
            ifish = new InverseFisherTransform(samplesize);
            //Crossing = new RollingWindow<IndicatorDataPoint>(samplesize);
            //FisherHistory = new RollingWindow<IndicatorDataPoint>(samplesize);
            Rvi = new RelativeVigorIndex(_symbol, samplesize);

            for (int x = 0; x < samplesize; x++)
            {
                //open.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //close.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //high.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //low.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //i1.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //instperiod.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //v1.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //v2.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //Rvi.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                unrealized.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                iFishes.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //Signal.Add(new IndicatorDataPoint(DateTime.MinValue, 0m));
                //Crossing.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m));

            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
        /// </summary>
        /// <seealso cref="QCAlgorithm.SetStartDate(System.DateTime)"/>
        /// <seealso cref="QCAlgorithm.SetEndDate(System.DateTime)"/>
        /// <seealso cref="QCAlgorithm.SetCash(decimal)"/>
        public override void Initialize()
        {
            //Initialize dates
            SetStartDate(2015, 6, 15);
            SetEndDate(2015, 6, 15);
            SetCash(25000);

            //Add as many securities as you like. All the data will be passed into the event handler:
            AddSecurity(SecurityType.Equity, symbol, Resolution.Minute);
            #region "Init indicators"
            Price = new RollingWindow<IndicatorDataPoint>(samplesize);
            ema = new RollingWindow<IndicatorDataPoint>(samplesize);
            zema = new RollingWindow<IndicatorDataPoint>(samplesize);
            OptimalValue1 = new RollingWindow<IndicatorDataPoint>(samplesize);
            OmtimalValue2 = new RollingWindow<IndicatorDataPoint>(samplesize);
            OptimalTrackingFilter = new RollingWindow<IndicatorDataPoint>(samplesize);
            lambda = new RollingWindow<IndicatorDataPoint>(samplesize);
            alpha = new RollingWindow<IndicatorDataPoint>(samplesize);
            priceOptimalDiff = new RollingWindow<IndicatorDataPoint>(samplesize);
            priceOptimalSign = new RollingWindow<IndicatorDataPoint>(samplesize);
            priceOptimalCross = new RollingWindow<IndicatorDataPoint>(samplesize);
            fudge = new RollingWindow<IndicatorDataPoint>(samplesize);
            instantTrend = new RollingWindow<IndicatorDataPoint>(samplesize);
            instantTrendTrigger = new RollingWindow<IndicatorDataPoint>(samplesize);
            cyberCycle = new RollingWindow<IndicatorDataPoint>(samplesize);
            centerGravity = new RollingWindow<IndicatorDataPoint>(samplesize);
            cyberCycleSmooth = new RollingWindow<IndicatorDataPoint>(samplesize);
            rvi = new RelativeVigorIndex(8);
            rviHistory = new RollingWindow<IndicatorDataPoint>(samplesize);

            stochCenterGravityValue1 = new RollingWindow<IndicatorDataPoint>(8);
            stochCenterGravityValue2 = new RollingWindow<IndicatorDataPoint>(8);

            stochCyberCycleValue1 = new RollingWindow<IndicatorDataPoint>(8);
            stochCyberCycleValue2 = new RollingWindow<IndicatorDataPoint>(8);
            stochCyberCycleInverseFisher = new RollingWindow<IndicatorDataPoint>(8);
            stochCyberCycleFisher = new RollingWindow<IndicatorDataPoint>(8);

            stochRviHistoryValue1 = new RollingWindow<IndicatorDataPoint>(8);
            stochRviHistoryValue2 = new RollingWindow<IndicatorDataPoint>(8);

            ROC = new RateOfChange(4);
            maxCyberCycle = new Maximum(8);
            minCyberCycle = new Minimum(8);
            #endregion
            //mylog.Debug(transheader);
            mylog.Debug(ondataheader);
            string msg = "Security,Date,Day Profit,Day Fees, Day Net, Total Profit, Total Fees";
            mylog.Debug(msg);
            mylog.Debug(tradeheader);
        }