extern double TakeProfit1 = 300.0; extern double TakeProfit2 = 500.0; extern double Lots = 0.01; extern double TrailingStop = 0.0; extern double StopLoss = 0.0; extern double MAper1=20; extern double MAper2=300; extern double MAper3=60; extern double MAper4=600; extern double ATRper=14; extern double RSIper=14; extern double CCIper=14; extern double Stochper=15; extern string LM3="---------------- Время"; extern int begin = 0; extern int end = 24; static int prevtime = 0; int start() { if(Time[0] == prevtime) return(0); prevtime = Time[0]; int li_76; int li_80 = 0; if (Bars < 100) { Print("bars less than 100"); return (0); } if (TakeProfit1 < 10.0) { Print("TakeProfit less than 10"); return (0); } if (AccountBalance() < 5000.0) { Alert("We have no money. Should be more than 5000. Balance = ", AccountBalance()); return (0); } if (AccountFreeMargin() < AccountBalance() / 2.0) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return (0); } double ld_0 = iMA(NULL, 0, MAper1, 0, MODE_EMA, PRICE_CLOSE, 0); double ld_8 = iMA(NULL, 0, MAper2, 0, MODE_EMA, PRICE_CLOSE, 0); double ld_16 = iMA(NULL, 0, MAper3, 0, MODE_EMA, PRICE_CLOSE, 0); double ld_24 = iMA(NULL, 0, MAper4, 0, MODE_EMA, PRICE_CLOSE, 0); double ld_32 = iATR(NULL, 0, ATRper, 0); double ld_40 = iRSI(NULL, 0, RSIper, PRICE_CLOSE, 0); double ld_48 = iCCI(NULL, 0, CCIper, PRICE_CLOSE, 0); double ld_56 = iStochastic(NULL, 0, Stochper, 3, 3, MODE_EMA, 0, MODE_MAIN, 0); double ld_64 = iStochastic(NULL, 0, Stochper, 3, 3, MODE_EMA, 0, MODE_SIGNAL, 0); li_80 = 0; //+------------------------------------------------------------------+ if(TimeHour(TimeCurrent()) >= begin && TimeHour(TimeCurrent()) < end) { //+------------------------------------------------------------------+ int li_84 = OrdersTotal(); for (int li_72 = 0; li_72 < li_84; li_72++) { OrderSelect(li_72, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) li_80++; } if (li_80 == 0) { if (ld_56 > ld_64 && ld_56 < 14.0) { Alert("Buy Now - " + Symbol()); Print(ld_0); Print(ld_8); Print(ld_64); Print(ld_64); li_76 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Bid-StopLoss * Point, Ask + TakeProfit1 * Point, "Bet-1H-[01-30pp]-[14-86]", 505, 0, Green); if (li_76 > 0) { if (OrderSelect(li_76, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); } else Print("Error opening BUY order : ", GetLastError()); return (0); } if (ld_56 < 5.0 && ld_64 < 10.0) { Alert("Buy Now - " + Symbol()); Print(ld_0); Print(ld_8); Print(ld_64); Print(ld_64); li_76 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Bid-StopLoss * Point, Ask + TakeProfit2 * Point, "Bet-1H-[01-50pp]-[low 5-10]", 505, 0, Green); if (li_76 > 0) { if (OrderSelect(li_76, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); } else Print("Error opening BUY order : ", GetLastError()); return (0); } if (ld_56 < ld_64 && ld_56 > 86.0) { Alert("Sell Now - " + Symbol()); li_76 = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, Ask+StopLoss * Point, Bid - TakeProfit1 * Point, "Bet-1H-[01-30pp]-[14-86]", 505, 0, Red); if (li_76 > 0) { if (OrderSelect(li_76, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); } else Print("Error opening SELL order : ", GetLastError()); return (0); } if (ld_64 > 90.0 && ld_56 > 95.0) { Alert("Sell Now - " + Symbol()); li_76 = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, Ask+StopLoss * Point, Bid - TakeProfit2 * Point, "Bet-1H-[01-50pp]-[High 90-95]", 505, 0, Red); if (li_76 > 0) { if (OrderSelect(li_76, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); } else Print("Error opening SELL order : ", GetLastError()); return (0); } return (0); } for (li_72 = 0; li_72 < li_84; li_72++) { OrderSelect(li_72, SELECT_BY_POS, MODE_TRADES); if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { if (OrderType() != OP_BUY) continue; if (ld_56 > 50.0 && ld_56 < ld_64) return (0); if (TrailingStop <= 0.0) continue; if (Bid - OrderOpenPrice() <= Point * TrailingStop) continue; if (OrderStopLoss() >= Bid - Point * TrailingStop) continue; OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, Green); return (0); } if (ld_56 < 50.0 && ld_56 > ld_64) return (0); if (TrailingStop > 0.0) { if (OrderOpenPrice() - Ask > Point * TrailingStop) { if (OrderStopLoss() > Ask + Point * TrailingStop || OrderStopLoss() == 0.0) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, Red); return (0); } } } } return (0); }}