/// <summary> /// candle finished event /// событие завершения свечи /// </summary> private void Strateg_CandleFinishedEvent(List <Candle> candles) { if (Regime.ValueString == "Off") { return; } _trendLine.Process(candles); _lastPcUp = GetLastFractail(Fractail.DataSeries.ByName("SeriesUp")); _lastPcDown = GetLastFractail(Fractail.DataSeries.ByName("SeriesDown")); _lastTrendUp = _trendLine.DataSeries.ByName("SeriesUp")[_trendLine.DataSeries.ByName("SeriesUp").Count - 1]; _lastTrendDown = _trendLine.DataSeries.ByName("SeriesDown")[_trendLine.DataSeries.ByName("SeriesDown").Count - 1]; _lastfastma = _FastMa.DataSeries.ByName("Ma")[_FastMa.DataSeries.ByName("Ma").Count - 1]; _lastslowma = _SlowMa.DataSeries.ByName("Ma")[_FastMa.DataSeries.ByName("Ma").Count - 1]; if (_lastPcUp == 0 || _lastPcDown == 0) { return; } List <Position> openPositions = _tab.PositionsOpenAll; if (openPositions != null && openPositions.Count != 0) { LogicClosePosition(); } if (_lastTrendUp == 0 || _lastTrendDown == 0) { return; } /* * if(candles[candles.Count-1].High > _lastTrendUp || candles[candles.Count - 1].Low < _lastTrendDown) ||{ || return; ||} */ if (Regime.ValueString == "OnlyClosePosition") { return; } if (openPositions == null || openPositions.Count == 0) { LogicOpenPosition(candles); } }
// logic логика /// <summary> /// candle finished event /// событие завершения свечи /// </summary> private void Strateg_CandleFinishedEvent(List <Candle> candles) { if (Regime.ValueString == "Off") { return; } _pc.LenghtUpLine = LengthUp.ValueInt; _pc.LenghtDownLine = LengthDown.ValueInt; _pc.Process(candles); _atr.Lenght = LengthAtr.ValueInt; _atr.Process(candles); Fractail.Process(candles); if (_pc.ValuesUp == null || _pc.ValuesDown == null || _atr.Values == null) { return; } if (GetLastFractail(Fractail.DataSeries.ByName("SeriesUp")) == 0 || GetLastFractail(Fractail.DataSeries.ByName("SeriesDown")) == 0) { return; } _lastPcUp = _pc.ValuesUp[_pc.ValuesUp.Count - 1]; _lastPcDown = _pc.ValuesDown[_pc.ValuesDown.Count - 1]; _lastAtr = _atr.Values[_atr.Values.Count - 1]; if (_pc.ValuesUp == null || _pc.ValuesDown == null || _pc.ValuesUp.Count < _pc.LenghtUpLine + 1 || _pc.ValuesDown.Count < _pc.LenghtDownLine + 1 || _atr.Values == null || _atr.Values.Count < _atr.Lenght + 1) { return; } List <Position> openPositions = _tab.PositionsOpenAll; if (openPositions != null && openPositions.Count != 0) { LogicClosePosition(); } if (Regime.ValueString == "OnlyClosePosition") { return; } if (openPositions == null || openPositions.Count == 0) { LogicOpenPosition(candles); } }