/// <summary> /// This function will be called after running a strategy /// </summary> protected override void OnRun() { if (symbol == null || account == null || symbol.ConnectionId != account.ConnectionId) { Log("Incorrect input parameters... Symbol or Account are not specified or they have diffent connections.", StrategyLoggingLevel.Error); return; } var vendorName = Core.Connections.Connected.FirstOrDefault(c => c.Id == symbol.ConnectionId); var isLimitSupported = Core.GetOrderType(OrderType.Limit, symbol.ConnectionId) != null; if (!isLimitSupported && vendorName != null) { Log($"The '{vendorName}' doesn't support '{OrderType.Limit}' order type.", StrategyLoggingLevel.Error); return; } _historicalData = symbol.GetHistory(period, Core.TimeUtils.DateTimeUtcNow); // ??? _historicalData.AddIndicator(_maIndicator); _historicalData.AddIndicator(_rsiIndicator); _historicalData.NewHistoryItem += this._historicalData_NewHistoryItem; _historicalData.HistoryItemUpdated += this._historicalData_HistoryItemUpdated; maxPeriod = new int[] { SMAPeriod, RSIPeriod }.Max(); }
protected override void OnRun() { if (symbol == null || account == null || symbol.ConnectionId != account.ConnectionId) { Log("Incorrect input parameters... Symbol or Account are not specified or they have diffent connections.", StrategyLoggingLevel.Error); return; } threeMaIndicator = Core.Instance.Indicators.BuiltIn.MAS3(ShortMaPeriod, MiddleMaPeriod, LongMaPeriod, BARS_THREE_MA_INTERVAL); historicalData = symbol.GetHistory(period, symbol.HistoryType, DateTime.UtcNow); historicalData.AddIndicator(threeMaIndicator); tradingState = TradingState.ExitMarket; longOrdersCount = 0; shortOrdersCount = 0; maxPeriod = Enumerable.Max(new double[] { ShortMaPeriod, MiddleMaPeriod, LongMaPeriod }); symbol.NewQuote += OnNewQuote; symbol.NewLast += OnNewLast; }