コード例 #1
0
ファイル: IntradayBuyLow1_3.cs プロジェクト: sprgn/LeanITrend
        //Dictionary<string, ExponentialMovingAverage[]> ema = new Dictionary<string, ExponentialMovingAverage[]>();



        /// <summary>
        /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
        /// </summary>
        public override void Initialize()
        {
            SetStartDate(2013, 10, 7);   //Set Start Date
            SetEndDate(2013, 10, 11);    //Set End Date
            SetCash(100000);             //Set Strategy Cash

            foreach (string symbol in symbols)
            {
                Strategy.Add(symbol, new BuyLowStrategy(previousDays, runsPerDay));
                previousStockProfit.Add(symbol, 0m);
                actualStockProfit.Add(symbol, 0m);

                AddSecurity(SecurityType.Equity, symbol, Resolution.Minute, true, maxLeverage, false);


                //tradier does 1 dollar equity trades
                Securities[symbol].TransactionModel = new ConstantFeeTransactionModel(1.00m);


                HullMovingAverage        HMA      = new HullMovingAverage("myHull", 4);
                Func <BaseData, decimal> selector = null;
                RegisterIndicator(symbol, HMA, Resolution.Minute, selector);

                hma.Add(symbol, HMA);


                stockShareSize.Add(symbol, maxLeverage / symbols.Length);
            }
        }
コード例 #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()
        {
            //mylog.Debug(transheader);
            mylog.Debug(ondataheader);

            //Initialize dates
            SetStartDate(2015, 5, 13);
            SetEndDate(2015, 5, 13);
            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);

            Price = new RollingWindow<IndicatorDataPoint>(14);
            hma7 = new HullMovingAverage("hma7", 7);
            hma14 = new HullMovingAverage("hma14",14);
            hma28 = new HullMovingAverage("hma28",28);
            instantTrend = new RollingWindow<IndicatorDataPoint>(7);
        }
コード例 #3
0
        private decimal a = .05m;  // used in instantTrend


        /// <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(transheader);
            mylog.Debug(ondataheader);

            //Initialize dates
            SetStartDate(2015, 5, 13);
            SetEndDate(2015, 5, 13);
            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);


            Price        = new RollingWindow <IndicatorDataPoint>(14);
            hma7         = new HullMovingAverage("hma7", 7);
            hma14        = new HullMovingAverage("hma14", 14);
            hma28        = new HullMovingAverage("hma28", 28);
            instantTrend = new RollingWindow <IndicatorDataPoint>(7);
        }
コード例 #4
0
ファイル: BELKHAYATEPRC.cs プロジェクト: zeropool/Vigoth
        protected override void OnStart()
        {
            DragonID = "Golden Dragon " + Symbol.Code + "-" + DragonNumber;

            Count          = BuyWait;
            BuyVolume      = OpeningLotSize;
            Quantity       = BuyVolume;
            OpeningBalance = Account.Balance;

            MaxLong  = MaxLongTrades;
            MaxShort = MaxShortTrades;

            cog  = Indicators.GetIndicator <BelkhayatePRC>(cogDegree, cogPeriod, Inner, Middle, Outer);
            hull = Indicators.GetIndicator <HullMovingAverage>(HullPeriod);

            if (atr1Period > 0 && atr2Period > 0)
            {
                atr1 = Indicators.AverageTrueRange(atr1Period, atr1Type);
                atr2 = Indicators.AverageTrueRange(atr2Period, atr2Type);
            }

            Message(0, "Dragon awakening...");

            foreach (var position in Account.Positions)
            {
                if (position.Label == DragonID)
                {
                    BotBalance += position.GrossProfit;
                    switch (position.TradeType)
                    {
                    case TradeType.Buy:
                        LongPositions++;
                        break;

                    case TradeType.Sell:
                        ShortPositions++;
                        break;
                    }
                }
            }

            if (LongPositions > 0 || ShortPositions > 0)
            {
                Message(0, "Found " + LongPositions + " half-eaten eagle(s) and " + ShortPositions + " rotting sheep");
            }
            else
            {
                Message(0, "No open trades found");
            }

            ChartRefresh();

            filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), DragonID + ".txt");

            if (MartingaleEnabled && File.Exists(filePath))
            {
                _fileReader      = File.OpenText(filePath);
                MartingaleActive = Int32.Parse(_fileReader.ReadLine());
                Message(0, "Martingale Level : " + MartingaleActive);
                _fileReader.Close();
            }
        }