示例#1
0
        public event Action <MarketFaze> MarketFazeChangeEvent; // событие изменения фазы рынка

        #endregion

        /// <summary>
        /// Конструктор класса робота
        /// </summary>
        /// <param name="name">имя робота</param>
        /// <param name="startProgram">программа, которая запустила робота</param>
        public OneLegArbitrageMy(string name, StartProgram startProgram) : base(name, startProgram)
        {
            //Запоминаем имя программы, которая запустила бота
            //Это может быть тестер, оптимизатор, терминал
            _startProgram = startProgram;

            //Создаем вкладки бота
            TabCreate(BotTabType.Simple);
            TabCreate(BotTabType.Index);

            _tabSec   = TabsSimple[0];
            _tabIndex = TabsIndex[0];

            // создаем настроечные параметры робота
            LenghtMa           = CreateParameter("Lenght MA", 100, 50, 200, 10);
            LenghtBollinger    = CreateParameter("Lenght Bollinger", 100, 50, 200, 10);
            DeviationBollinger = CreateParameter("Deviation Bollinger", 1, 0.5m, 2.5m, 0.5m);
            LenghtAtr          = CreateParameter("Lenght ATR", 20, 20, 100, 10);
            MultiplyAtr        = CreateParameter("Multiplay ATR", 1, 1, 5, 0.5m);

            // cоздаем индикаторы
            _ma        = new MovingAverage(name + "MA", false);
            _ma        = (MovingAverage)_tabIndex.CreateCandleIndicator(_ma, "Prime");
            _ma.Lenght = LenghtMa.ValueInt;
            _ma.Save();

            _bollinger           = new Bollinger(name + "Bollinger", false);
            _bollinger           = (Bollinger)_tabIndex.CreateCandleIndicator(_bollinger, "Prime");
            _bollinger.Lenght    = LenghtBollinger.ValueInt;
            _bollinger.Deviation = DeviationBollinger.ValueDecimal;
            _bollinger.Save();

            _atr        = new Atr(name + "ATR", false);
            _atr        = (Atr)_tabIndex.CreateCandleIndicator(_atr, "Second");
            _atr.Lenght = LenghtAtr.ValueInt;
            _atr.Save();

            // загружаем настроечные параметры робота
            Load();

            // подписываемся на события
            _tabIndex.SpreadChangeEvent += TabIndex_SpreadChangeEvent;
            _tabSec.CandleFinishedEvent += TabSec_CandleFinishedEvent;
            ParametrsChangeByUser       += OneLegArbitrage_ParametrsChangeByUser;
            DeleteEvent += OneLegArbitrage_DeleteEvent;
            //todo доработать OneLegArbitrage_DeleteEvent, чтобы удалялись все файлы робота
        }
示例#2
0
        public FractialMA_work(string name, StartProgram startProgram)
            : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _pc = new PriceChannel(name + "PriceChannel", false)
            {
                LenghtUpLine = 3, LenghtDownLine = 3, ColorUp = Color.DodgerBlue, ColorDown = Color.DarkRed
            };
            _atr = new Atr(name + "ATR", false)
            {
                Lenght = 14, ColorBase = Color.DodgerBlue,
            };

            _pc.Save();
            _atr.Save();

            _tab.CandleFinishedEvent        += Strateg_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += Strateg_PositionOpen;
            _tab.PositionOpeningFailEvent   += Strateg_PositionOpeningFailEvent;
            _tab.PositionClosingSuccesEvent += Strateg_PositionClosingSuccesEvent;
            Regime = CreateParameter("Regime", "Off", new[] { "Off", "On", "OnlyClosePosition", "OnlyShort", "OnlyLong" });

            Slipage    = CreateParameter("Slipage", 0m, 0m, 20, 0.1m);
            VolumeFix1 = CreateParameter("VolumeFix1", 0m, 0.01m, 20, 0.01m);
            VolumeFix2 = CreateParameter("VolumeFix2", 0m, 0.01m, 20, 0.01m);

            LengthAtr  = CreateParameter("LengthAtr", 14, 0, 200, 1);
            LengthUp   = CreateParameter("LengthUp", 3, 0, 200, 1);
            LengthDown = CreateParameter("LengthDown", 3, 0, 200, 1);
            //Slipage = 10;
            //VolumeFix1 = 1;
            //VolumeFix2 = 1;
            //LengthAtr = 14;
            KofAtr = 0.5m;
            //LengthUp = 3;
            //LengthDown = 3;

            DeleteEvent += Strategy_DeleteEvent;

            Thread closerThread = new Thread(CloseFailPosition);

            closerThread.IsBackground = true;
            closerThread.Start();
        }
示例#3
0
        // сервис
        public StrategyBearish(string name, StartProgram startProgram) : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _atr = new Atr(name + "Atr", false)
            {
                Lenght    = 14,
                ColorBase = Color.DodgerBlue,
                PaintOn   = true,
            };

            _atr = _tab.CreateCandleIndicator(_atr, "atrArea");
            _atr.Save();

            _chandelier = new Line(name + "chandelier", false)
            {
                ColorBase = Color.DodgerBlue,
                PaintOn   = true,
            };

            _chandelier = _tab.CreateCandleIndicator(_chandelier, "Prime");
            _chandelier.Save();

            _alert      = new AlertToPrice(NameStrategyUniq);
            _alert.IsOn = false;
            _tab.DeleteAllAlerts();
            _tab.SetNewAlert(_alert);

            _tab.CandleFinishedEvent += StrategyAdxVolatility_CandleFinishedEvent;

            IsOn                = false;
            Volume              = 1;
            SlipageOpenSecond   = 0;
            SlipageCloseSecond  = 0;
            TimeFrom            = 10;
            TimeTo              = 22;
            AlertIsOn           = false;
            SlipageToAlert      = 10;
            LagTimeToOpenClose  = new TimeSpan(0, 0, 0, 15);
            LagPunctToOpenClose = 20;
            EmulatorIsOn        = false;

            Multiple       = 1.5m;
            WhiteJohnson   = 1;
            ChandelierMult = 4m;

            Load();

            Thread worker = new Thread(TimeWatcherArea);

            worker.IsBackground = true;
            worker.Start();

            Thread worker2 = new Thread(WatcherOpenPosition);

            worker2.IsBackground = true;
            worker2.Start();

            Thread worker3 = new Thread(AreaCloserPositionThread);

            worker3.IsBackground = true;
            worker3.Start();

            _tab.OrderUpdateEvent         += _tab_OrderUpdateEvent;
            _tab.NewTickEvent             += _tab_NewTickEvent;
            _tab.PositionClosingFailEvent += _tab_PositionClosingFailEvent;
            _tab.PositionOpeningFailEvent += _tab_PositionOpeningFailEvent;
        }
示例#4
0
        public EnvelopTrendBitmex(string name, StartProgram startProgram) : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _tab.CandleFinishedEvent        += _tab_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += _tab_PositionOpeningSuccesEvent;
            _tab.PositionClosingSuccesEvent += _tab_PositionClosingSuccesEvent;
            _envelop = new Envelops(name + "Envelop", false);
            _envelop = (Envelops)_tab.CreateCandleIndicator(_envelop, "Prime");
            _envelop.Save();

            _atr = new Atr(name + "ATR", false)
            {
                Lenght = 14, ColorBase = Color.DodgerBlue,
            };
            _atr.Save();

            this.ParametrsChangeByUser += EnvelopTrendBitmex_ParametrsChangeByUser;
            this.DeleteEvent           += Strategy_DeleteEvent;

            Regime   = CreateParameter("Regime", "Off", new[] { "Off", "On", "OnlyClosePosition", "OnlyShort", "OnlyLong" });
            RegimeML = CreateParameter("RegimeML", "Off", new[] { "Off", "Parser", "Client" });

            Slippage            = CreateParameter("Slippage", 0, 0, 20, 1);
            EnvelopDeviation    = CreateParameter("Envelop Deviation", 0.3m, 0.3m, 4, 0.1m);
            EnvelopMovingLength = CreateParameter("Envelop Moving Length", 10, 10, 200, 5);
            TrailStop           = CreateParameter("Trail Stop", 0.1m, 0m, 5, 0.1m);
            MinProfitTraling    = CreateParameter("Минимальный профит для трэйлинга", 0.2m, 0.2m, 2, 0.1m);
            leverage            = CreateParameter("Маржинальное плечо", 0.1m, 0.1m, 10, 0.1m);
            MaxStop             = CreateParameter("MaxStop", 1, 1, 10, 0.1m);
            isContract          = CreateParameter("Торгуем контрактами", false);
            DepoCurrency        = CreateParameter("DepoCurrency", "Currency2", new[] { "Currency1", "Currency2" });
            VolumeDecimals      = CreateParameter("Volume Decimals", 0, 0, 20, 1);

            FastMA = new MovingAverage(name + "FastMA", false)
            {
                ColorBase = System.Drawing.Color.Yellow, Lenght = 15, TypePointsToSearch = PriceTypePoints.Close, TypeCalculationAverage = MovingAverageTypeCalculation.Simple
            };
            FastMA        = (MovingAverage)_tab.CreateCandleIndicator(FastMA, "Prime");
            FastMA.Lenght = 15;
            FastMA.Save();

            SlowMA = new MovingAverage(name + "SlowMA", false)
            {
                ColorBase = System.Drawing.Color.Blue, Lenght = 30, TypePointsToSearch = PriceTypePoints.Close, TypeCalculationAverage = MovingAverageTypeCalculation.Simple
            };
            SlowMA        = (MovingAverage)_tab.CreateCandleIndicator(SlowMA, "Prime");
            SlowMA.Lenght = 30;
            SlowMA.Save();

            _envelop.Deviation            = EnvelopDeviation.ValueDecimal;
            _envelop.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;
            _name = name;

            #region ML Region
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            Load();
            if (RegimeML.ValueString != "Off") // создаем файл(ы) если несуществуют и очищаем если существуют
            {
                initML();
            }
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            #endregion
        }
示例#5
0
        public PriceChanel_work(string name, StartProgram startProgram)
            : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _pc = new PriceChannel(name + "PriceChannel", false)
            {
                LenghtUpLine = 3, LenghtDownLine = 3, ColorUp = Color.DodgerBlue, ColorDown = Color.DarkRed
            };
            _atr = new Atr(name + "ATR", false)
            {
                Lenght = 14, ColorBase = Color.DodgerBlue,
            };

            _pc.Save();
            _atr.Save();

            _tab.CandleFinishedEvent        += Strateg_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += Strateg_PositionOpen;
            _tab.PositionOpeningFailEvent   += Strateg_PositionOpeningFailEvent;
            _tab.PositionClosingSuccesEvent += Strateg_PositionClosingSuccesEvent;
            this.ParametrsChangeByUser      += PriceChanel_work_ParametrsChangeByUser;
            _tab.BestBidAskChangeEvent      += _tab_BestBidAskChangeEvent;

            Regime        = CreateParameter("Regime", "Off", new[] { "Off", "On", "OnlyClosePosition", "OnlyShort", "OnlyLong" });
            leverage      = CreateParameter("Маржинальное плечо", 1m, 1m, 10, 0.1m);
            DepoCurrency  = CreateParameter("DepoCurrency", "Currency2", new[] { "Currency1", "Currency2" });
            isContract    = CreateParameter("Торгуем контрактами", false);
            MaxStop       = CreateParameter("MaxStop", 1, 1, 10, 0.1m);
            Fractaillenth = CreateParameter("Длина фрактала", 51, 5, 200, 1);

            Slipage = CreateParameter("Slipage", 0m, 0m, 20, 0.1m);

            LengthAtr  = CreateParameter("LengthAtr", 14, 14, 200, 1);
            LengthUp   = CreateParameter("LengthUp", 14, 14, 200, 1);
            LengthDown = CreateParameter("LengthDown", 14, 14, 200, 1);

            LengthPC = CreateParameter("Длина скользящей для PriceChannel", 14, 14, 200, 1);

            LengthAtr.ValueInt  = LengthPC.ValueInt;
            LengthUp.ValueInt   = LengthPC.ValueInt;
            LengthDown.ValueInt = LengthPC.ValueInt;

            //Slipage = 10;
            //VolumeFix1 = 1;
            //VolumeFix2 = 1;
            //LengthAtr = 14;
            KofAtr = 0.5m;
            //LengthUp = 3;
            //LengthDown = 3;

            DeleteEvent += Strategy_DeleteEvent;

            FastMA = new MovingAverage(name + "FastMA", false)
            {
                ColorBase = System.Drawing.Color.Yellow, Lenght = 15, TypePointsToSearch = PriceTypePoints.Close, TypeCalculationAverage = MovingAverageTypeCalculation.Simple
            };
            FastMA        = (MovingAverage)_tab.CreateCandleIndicator(FastMA, "Prime");
            FastMA.Lenght = 15;
            FastMA.Save();

            SlowMA = new MovingAverage(name + "SlowMA", false)
            {
                ColorBase = System.Drawing.Color.Blue, Lenght = 30, TypePointsToSearch = PriceTypePoints.Close, TypeCalculationAverage = MovingAverageTypeCalculation.Simple
            };
            SlowMA        = (MovingAverage)_tab.CreateCandleIndicator(SlowMA, "Prime");
            SlowMA.Lenght = 30;
            SlowMA.Save();

            Fractail = IndicatorsFactory.CreateIndicatorByName("Fractail_lenth", name + "Fractail", false);
            Fractail = (Aindicator)_tab.CreateCandleIndicator(Fractail, "Prime");
            Fractail.ParametersDigit[0].Value = Fractaillenth.ValueInt;
            Fractail.Save();

            Thread closerThread = new Thread(CloseFailPosition);

            closerThread.IsBackground = true;
            closerThread.Start();
        }