private void MarketDepth_Updated() { if ((int)Server.Time.DayOfWeek == NewsDay && !_ordersCreated) { var triggerTime = new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, NewsHour, NewsMinute, 0); if (Server.Time <= triggerTime && (triggerTime - Server.Time).TotalSeconds <= SecondsBefore) { _ordersCreated = true; DateTime expirationTime = triggerTime.AddSeconds(SecondsTimeout); double sellOrderTargetPrice = Symbol.Bid - PipsAway * Symbol.PipSize; Trade.CreateSellStopOrder(Symbol, Volume, sellOrderTargetPrice, sellOrderTargetPrice + StopLoss * Symbol.PipSize, sellOrderTargetPrice - TakeProfit * Symbol.PipSize, expirationTime); double buyOrderTargetPrice = Symbol.Ask + PipsAway * Symbol.PipSize; Trade.CreateBuyStopOrder(Symbol, Volume, buyOrderTargetPrice, buyOrderTargetPrice - StopLoss * Symbol.PipSize, buyOrderTargetPrice + TakeProfit * Symbol.PipSize, expirationTime); } } }
private void Pattern(int last) { double op, sl = 0, tp = 0; double irsi; double fractal; irsi = rsi.Result[last - 1]; double bbup = bb.Top[last - 1]; double bblow = bb.Bottom[last - 1]; if (frc.High[last - 3] != 0) { upfractal = frc.High[last - 3]; } if (frc.Low[last - 3] != 0) { dwfractal = frc.Low[last - 3]; } if (irsi > bbup && MarketSeries.Close[last - 1] < upfractal && okbuy == 0) { op = upfractal + otstup * Symbol.PointSize * mn; if (SL > 0) { sl = op - SL * Symbol.PointSize * mn; } if (TP > 0) { tp = op + TP * Symbol.PointSize * mn; } Trade.CreateBuyStopOrder(Symbol, Lot, op, sl, tp, null); okbuy = 1; Print("OK=" + okbuy.ToString()); } if (irsi < rsiup && okbuy == 1) { for (int i = 0; i < Account.PendingOrders.Count; i++) { if (Account.PendingOrders[i].TradeType == TradeType.Buy) { Trade.DeletePendingOrder(Account.PendingOrders[i]); } } okbuy = 0; } if (irsi < bblow && MarketSeries.Close[1] > dwfractal && oksell == 0) { op = dwfractal - otstup * Symbol.PointSize * mn; if (SL > 0) { sl = op + SL * Symbol.PointSize * mn; } if (TP > 0) { tp = op - TP * Symbol.PointSize * mn; } Trade.CreateSellStopOrder(Symbol, Lot, op, sl, tp, null); oksell = 1; } if (irsi > rsidw && oksell == 1) { for (int i = 0; i < Account.PendingOrders.Count; i++) { if (Account.PendingOrders[i].TradeType == TradeType.Sell) { Trade.DeletePendingOrder(Account.PendingOrders[i]); } } okbuy = 0; } }