private void OnNewOrderTrades(IEnumerable <MyTrade> trades) { // для каждой сделки добавляем защитную пару стратегии /* * var protectiveStrategies = trades.Select(t => * { * // выставляет стоп-лосс в deflevel пунктов * var stopLoss = new StopLossStrategy(t, deflevel); * stopLoss.IsTrailing = true; * return stopLoss; * }); * * //ChildStrategies.AddRange(protectiveStrategies); * foreach (var st in protectiveStrategies) * ChildStrategies.Add(st); * */ StopLossStrategy stopLoss = new StopLossStrategy(trades.ToArray <MyTrade>()[0], 40); stopLoss.IsTrailing = true; stopLoss.WhenError().Do(() => { this.AddInfoLog("ololo"); }); stopLoss.WhenNewMyTrades().Do(() => { this.AddInfoLog("ololo111"); }); ChildStrategies.Add(stopLoss); }
private void ProtectMyNewTrades(IEnumerable<MyTrade> trades) { foreach (MyTrade trade in trades) { var takeProfit = new TakeProfitStrategy(trade, this.TakeProfitUnit) { UseQuoting = this.UseQuoting, IsTrailing = true, BestPriceOffset = this.BestPriceOffset, PriceOffset = 1 }; var stopLoss = new StopLossStrategy(trade, this.StopLossUnit) { UseQuoting = this.UseQuoting, IsTrailing = true, BestPriceOffset = this.BestPriceOffset, PriceOffset = 1 }; var takeProfitStopLoss = new TakeProfitStopLossStrategy(takeProfit, stopLoss); ChildStrategies.Add(takeProfitStopLoss); //var stopLoss = new StopLossCandleStrategy(this.CandleSeries, trade, this.StopLossUnit); //ChildStrategies.Add(stopLoss); this.AddInfoLog("Hurrah, we have new trade (#{0}) and I've protected it.", trade.Trade.Id); }; }