diff --git a/KLHZ.Trader.Core/Exchange/Services/Trader.cs b/KLHZ.Trader.Core/Exchange/Services/Trader.cs index e53624e..952d018 100644 --- a/KLHZ.Trader.Core/Exchange/Services/Trader.cs +++ b/KLHZ.Trader.Core/Exchange/Services/Trader.cs @@ -281,7 +281,7 @@ namespace KLHZ.Trader.Core.Exchange.Services } await LogDeclision(DeclisionTradeAction.CloseShort, message); } - if (newMod == TradingMode.Growing && newMod != oldMod) + if (newMod == TradingMode.Growing && newMod != oldMod && !LongOpeningStops.ContainsKey(message.Figi)) { var stops = GetStops(message, PositionType.Long); if (!message.IsHistoricalData && BotModeSwitcher.CanPurchase()) @@ -292,12 +292,13 @@ namespace KLHZ.Trader.Core.Exchange.Services .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Long, stops.stopLoss, stops.takeProfit, 1); + LongOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenLong, message); await LogDeclision(DeclisionTradeAction.OpenLong, message.Value + stops.takeProfit, message.Time.AddMilliseconds(-RandomNumberGenerator.GetInt32(300, 1000)), message); await LogDeclision(DeclisionTradeAction.OpenLong, message.Value - stops.stopLoss, message.Time.AddMilliseconds(RandomNumberGenerator.GetInt32(300, 1000)), message); } - if (newMod == TradingMode.Dropping && newMod != oldMod) + if (newMod == TradingMode.Dropping && newMod != oldMod && !ShortOpeningStops.ContainsKey(message.Figi)) { var stops = GetStops(message, PositionType.Short); if (!message.IsHistoricalData && BotModeSwitcher.CanSell()) @@ -308,6 +309,7 @@ namespace KLHZ.Trader.Core.Exchange.Services .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Short, stops.stopLoss, stops.takeProfit, 1); + ShortOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenShort, message); await LogDeclision(DeclisionTradeAction.OpenShort, message.Value - stops.takeProfit, message.Time.AddMilliseconds(-RandomNumberGenerator.GetInt32(10, 100)), message); @@ -545,6 +547,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Long, stops.stopLoss, stops.takeProfit, 1); + LongOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenLong, message); @@ -565,6 +568,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Short, stops.stopLoss, stops.takeProfit, 1); + ShortOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenShort, message);