private float CalculateBrickSize() { if (lastPrices.Length < AutosizePeriod) { return(pointCost * brickSize); } if (VolatilityType == RencoVolatilityType.азмах) { return((lastPrices.Max(c => c.high) - lastPrices.Min(c => c.low)) * AutosizeScale); } //if (VolatilityType == RencoVolatilityType.ATR) return(lastPrices.Average(p => p.high - p.low) * AutosizeScale); }
private void OpenDeal(float price, int dealSide) { var dealVolumeDepo = CalculateVolume(ticker); if (dealVolumeDepo == 0) { return; } // Посчитать stopLoss и takeProfit stopLoss = StopLossPoints == 0 ? dealSide > 0 ? extremumQueue.Min(q => q.a) : extremumQueue.Max(q => q.a) : price - dealSide * DalSpot.Instance.GetAbsValue(ticker, (float)StopLossPoints); takeProfit = TakeProfitPoints == 0 ? extremumQueue.First.a : price + dealSide * DalSpot.Instance.GetAbsValue(ticker, (float)TakeProfitPoints); // очистить очередь экстремумов extremumQueue.Clear(); // открыть сделку robotContext.SendNewOrderRequest( protectedContext.MakeProtectedContext(), RequestUniqueId.Next(), new MarketOrder { AccountID = robotContext.AccountInfo.ID, Magic = Magic, Symbol = ticker, Volume = dealVolumeDepo, Side = dealSide, StopLoss = stopLoss, TakeProfit = takeProfit * TakeRange / 100, ExpertComment = "DoubleTopRobot" }, OrderType.Market, 0, 0); }