Ejemplo n.º 1
0
        public override async void Initialize(string data)
        {
            _platform.AddLog("MyBot", "Initialize ...");
            var gazp = _platform.GetInstrum("GAZP");

            if (gazp == null)
            {
                return;
            }

            _gazpId = gazp.InsID;
            _bars   = await _platform.CreateBarRow(gazp.InsID, Timeframes.Min, 5);

            _bars.OnCloseBar   += Bars_OnCloseBar;
            _bars.Close.Change += Close_Change;
            _platform.AddLog("MyBot", "Initialized");

            _platform.OnTick(gazp.InsID, OnTick, true);
            _platform.OnTimer(OnTimer);
        }
Ejemplo n.º 2
0
        public async override Task <IBotResult> Initialize(IBotParams botParams)
        {
            decimal summa = _platform.GetCurrentSumma();

            _platform.AddLog("MyBot", "Initialize ..." + summa.ToString());
            _gazp = _platform.GetInstrum("GAZP");
            if (_gazp == null)
            {
                return(_platform.BotError("Не найдет тикер"));
            }

            _bars1 = await _platform.CreateBarRow(_gazp.InsID, Timeframes.Min5, 5);

            if (_bars1 == null)
            {
                _platform.AddLog("MyBot", "Не создан BarRow");
                return(_platform.BotError("Не создан BarRow"));
            }
            _bars2 = await _platform.CreateBarRow(_gazp.InsID, Timeframes.Hour, 5);

            if (_bars2 == null)
            {
                _platform.AddLog("MyBot", "Не создан BarRow");
                return(_platform.BotError("Не создан BarRow"));
            }

            _bars1_ma          = new Ma(_bars1.Close, AverageMethod.Exponencial, 10);
            _bars1.OnCloseBar += Bars1_OnCloseBar;
            _bars1_ma.Change  += _bars1_ma_Change;

            _bars2_ma          = new Ma(_bars2.Close, AverageMethod.Exponencial, 10);
            _bars2.OnCloseBar += Bars2_OnCloseBar;

            _platform.OnTick(_gazp.InsID, OnTick, true);

            _platform.AddLog("MyBot", "Initialized");

            return(_platform.BotSuccess());
        }