コード例 #1
0
ファイル: Golden Dragon II.cs プロジェクト: Mikai47/cAlgoBot
        protected override void OnStart()
        {
            DragonID = "Golden Dragon " + DragonNumber + " - " + Symbol.Code;

            Positions.Closed += PositionsOnClosed;

            BuyVolume = TradeVolume;

            OpeningBalance = Account.Balance;

            MaxLong = MaxLongTrades;
            MaxShort = MaxShortTrades;

            cog1 = Indicators.GetIndicator<BelkhayatePolynomialRegression>(cogDegree, cog1Periods, Inner, Middle, Outer);

            if (cog2Periods > 0)
                cog2 = Indicators.GetIndicator<BelkhayatePolynomialRegression>(cogDegree, cog2Periods, Inner, Middle, Outer);

            if (cog3Periods > 0)
                cog3 = Indicators.GetIndicator<BelkhayatePolynomialRegression>(cogDegree, cog3Periods, Inner, Middle, Outer);

            if (BelkhayateTimingFilter)
                timing = Indicators.GetIndicator<BelkhayateTiming>();

            if (HullFilter)
                hull = Indicators.GetIndicator<HMA>(HullPeriod);

            // Identify existing trades from this instance
            foreach (var position in Positions)
            {
                if (position.Label == DragonID)
                    switch (position.TradeType)
                    {
                        case TradeType.Buy:
                            LongPositions++;
                            break;
                        case TradeType.Sell:
                            ShortPositions++;
                            break;
                    }
            }

        }
コード例 #2
0
ファイル: GoldenDragon.cs プロジェクト: redrhino/cAlgo.Base
        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<HMA>(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();
            }
        }