//+------------------------------------------------------------------+
//|                                     Copyright © 2010, Konstantin |
//|                        http://www.fxaktiv.com  admin@fxaktiv.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Konstantin"
#property link      "http://www.fxaktiv.com"
//+------------------------------------------------------------------+
 extern string _="общие настройки";
 extern double Lot =0.1;
 extern int TF = 5; 
 extern bool avtomatic = true;
 extern int sl = 1000;
 extern int tp = 1000;
 extern int CloseHour= 9;    //время закрытия всех позиций 
 int TradingDaysOfWeek[5] = {1,2,3,4,5};  
//+------------------------------------------------------------------+
 extern string __="настройки forex-bazar_8";
 extern bool      LevelSC_8=           true;//отключение советника по индюку    forex-bazar_8
 extern int       Magic_8 =            3878675;
 extern bool      bezubitok_8 =        true;
 extern int       uroven_bezubitok_8 = 1000;
 extern int       Profit_bezubitok_8 = 100; 
 extern bool      tral_8 =             true;
 extern int       uroven_tral_8 =      2000;    
 extern int       Hours2Check_8=       8;   //количество часов для измерения пробиваемого диапазона     
 extern int       CloseHour_8=         9;    //время закрытия всех позиций    
 extern int       EarliestOpenHour_8=  14;   //раньше этого часа не открываемся
 extern int       Days2Check_8=        10;    //количество суток для измерения среднего суточного диапазона
 extern double    ChannelK_8=          1.5;  //коэффициент рассчёта канала   
 extern int       CheckHour_8=         8;//12    //время измерения пробиваемого диапазона   
 extern double    ProfitK_8=           2;//2    //коэффициент рассчёта профита
 extern double    LossK_8=             2;//1.5    //коэффициент рассчёта лосса  
 extern double    OffsetK_8=           2;//2.5  //коэффициент рассчёта расстояния пробоя    
//+------------------------------------------------------------------+  
 extern string ___="настройки forex-bazar_12";
 extern bool      LevelSC_12=          true;//отключение советника по индюку    forex-bazar_12
 extern int       Magic_12 =           9257564;  
 extern bool      bezubitok_12 =       true;
 extern int       uroven_bezubitok_12= 1000;
 extern int       Profit_bezubitok_12= 100; 
 extern bool      tral_12 =            true;
 extern int       uroven_tral_12 =     2000;  
 extern int       Hours2Check_12=      8;   //количество часов для измерения пробиваемого диапазона     
 extern int       CloseHour_12=        9;    //время закрытия всех позиций    
 extern int       EarliestOpenHour_12= 14;   //раньше этого часа не открываемся
 extern int       Days2Check_12=       10;    //количество суток для измерения среднего суточного диапазона
 extern double    ChannelK_12=         1.5;  //коэффициент рассчёта канала   
 extern int       CheckHour_12=        12;//12    //время измерения пробиваемого диапазона   
 extern double    ProfitK_12=          2;//2    //коэффициент рассчёта профита
 extern double    LossK_12=            1.5;//1.5    //коэффициент рассчёта лосса  
 extern double    OffsetK_12=          2.5;//2.5  //коэффициент рассчёта расстояния пробоя  
//+------------------------------------------------------------------+ 
 int trade_8,trade_12;
//+------------------------------------------------------------------+
 int orders(int type,int mag){int j=0;for(int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)if((OrderType()==type)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol()))j++;}return(j);}
 void Send_buy(double SL,double TP,int mag){if(DayOfWeek()==TradingDaysOfWeek[1]||DayOfWeek()==TradingDaysOfWeek[2]||DayOfWeek()==TradingDaysOfWeek[3]||DayOfWeek()==TradingDaysOfWeek[4]||DayOfWeek()==TradingDaysOfWeek[6])if(Bid-SL>=MarketInfo(Symbol(),MODE_STOPLEVEL)*Point&&TP-Bid>=MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)OrderSend(Symbol(),OP_BUY,Lot,Ask,10,SL,TP,WindowExpertName()+"buy",mag,0,Blue);}  
 void Send_sell(double SL,double TP,int mag){if(DayOfWeek()==TradingDaysOfWeek[1]||DayOfWeek()==TradingDaysOfWeek[2]||DayOfWeek()==TradingDaysOfWeek[3]||DayOfWeek()==TradingDaysOfWeek[4]||DayOfWeek()==TradingDaysOfWeek[6])if(SL-Ask>=MarketInfo(Symbol(),MODE_STOPLEVEL)*Point&&Ask-TP>=MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)OrderSend(Symbol(),OP_SELL,Lot,Bid,10,SL,TP,WindowExpertName()+"sell",mag,0,Red);}
 void Send_buy2(int mag){if(DayOfWeek()==TradingDaysOfWeek[1]||DayOfWeek()==TradingDaysOfWeek[2]||DayOfWeek()==TradingDaysOfWeek[3]||DayOfWeek()==TradingDaysOfWeek[4]||DayOfWeek()==TradingDaysOfWeek[6])OrderSend(Symbol(),OP_BUY,Lot,Ask,10,Bid-sl*Point,Ask+tp*Point,WindowExpertName()+"buy",mag,0,Blue);}  
 void Send_sell2(int mag){if(DayOfWeek()==TradingDaysOfWeek[1]||DayOfWeek()==TradingDaysOfWeek[2]||DayOfWeek()==TradingDaysOfWeek[3]||DayOfWeek()==TradingDaysOfWeek[4]||DayOfWeek()==TradingDaysOfWeek[6])OrderSend(Symbol(),OP_SELL,Lot,Bid,10,Ask+sl*Point,Bid-tp*Point,WindowExpertName()+"sell",mag,0,Red);}
 int ALLCloseBUY(int mag){RefreshRates();for(int i=OrdersTotal(); i+1>=0; i--){if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)&&(OrderType()==OP_BUY)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol()))OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(Symbol(),MODE_SPREAD));}}
 int ALLCloseSELL(int mag){RefreshRates();for(int i=OrdersTotal(); i+1>=0; i--){if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)&&(OrderType()==OP_SELL)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol()))OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(Symbol(),MODE_SPREAD));}}
 void bezubitok_sl_buy(int mag,int pr){for(int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){if((OrderType()==OP_BUY)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol())){OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+pr*Point,OrderTakeProfit(),0);}}}}
 void bezubitok_sl_sell(int mag,int pr){for(int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){if((OrderType()==OP_SELL)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol())) {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-pr*Point,OrderTakeProfit(),0);}}}}
 void modify_sl_buy(int mag,int tral){for(int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){if((OrderType()==OP_BUY)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol())){OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+(Bid-OrderStopLoss()-tral*Point-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point),OrderTakeProfit(),0);}}}}
 void modify_sl_sell(int mag,int tral){for(int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){if((OrderType()==OP_SELL)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol())) {OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()-(OrderStopLoss()-Ask-tral*Point-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point),OrderTakeProfit(),0);}}}}
 double OrderOpenPricE(int mag){double j=0;for (int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){if((OrderType()==OP_BUY||OrderType()==OP_SELL)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol()))j=OrderOpenPrice();}}return(j);}
 double OrderStopLosS(int mag){double j=0;for (int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){if((OrderType()==OP_BUY||OrderType()==OP_SELL)&&(OrderMagicNumber()==mag)&&(OrderSymbol()==Symbol()))j=OrderStopLoss();}}return(j);}
//+------------------------------------------------------------------+
int start()
 {
 if(Period()!=TF)return(0);
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж+
 static int time;if(Time[0]==time)return(0);time=Time[0];   
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж+ 
 if((LevelSC_8==true)&&(avtomatic==true)){double ClosE_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,2,0);if(ClosE_8>1000)ClosE_8=0;
 double SignalBUY_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,3,0);if(SignalBUY_8>1000)SignalBUY_8=0;
 double SignalSELL_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,4,0);if(SignalSELL_8>1000)SignalSELL_8=0;
 double TP_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,6,0);if(TP_8>1000)TP_8=0;
 double SL_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,7,0);if(SL_8>1000)SL_8=0; 
 if((ClosE_8>0)&&(orders(OP_BUY,Magic_8)+orders(OP_SELL,Magic_8)>0)){ALLCloseBUY(Magic_8);ALLCloseSELL(Magic_8);}
 if((orders(OP_BUY,Magic_8)+orders(OP_SELL,Magic_8)==0)&&(SignalBUY_8==0)&&(SignalSELL_8==0))trade_8=0;
 if((orders(OP_BUY,Magic_8)+orders(OP_SELL,Magic_8)>0))trade_8=1; 
 if((trade_8==0)&&(SignalBUY_8>0)&&(TP_8>0)&&(SL_8>0)&&(orders(OP_BUY,Magic_8)==0)){Send_buy(SL_8,TP_8,Magic_8);}
 if((trade_8==0)&&(SignalSELL_8>0)&&(TP_8>0)&&(SL_8>0)&&(orders(OP_SELL,Magic_8)==0)){Send_sell(SL_8,TP_8,Magic_8);}
 if(bezubitok_8==true){if((orders(OP_BUY,Magic_8)>0)&&(NormalizeDouble(OrderStopLosS(Magic_8),4)<NormalizeDouble(OrderOpenPricE(Magic_8),4))&&(Bid-OrderOpenPricE(Magic_8)>uroven_bezubitok_8*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_8*Point)){bezubitok_sl_buy(Magic_8,Profit_bezubitok_8);}
 if((orders(OP_SELL,Magic_8)>0)&&(NormalizeDouble(OrderStopLosS(Magic_8),4)>NormalizeDouble(OrderOpenPricE(Magic_8),4))&&(OrderOpenPricE(Magic_8)-Ask>uroven_bezubitok_8*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_8*Point)){bezubitok_sl_sell(Magic_8,Profit_bezubitok_8);}}
 if(tral_8==true){if((orders(OP_BUY,Magic_8)>0)&&(Bid-OrderOpenPricE(Magic_8)>tral_8*Point)&&(Bid-OrderStopLosS(Magic_8)>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_8)*Point)){modify_sl_buy(Magic_8,tral_8);}
 if((orders(OP_SELL,Magic_8)>0)&&(OrderOpenPricE(Magic_8)-Ask>tral_8*Point)&&(OrderStopLosS(Magic_8)-Ask>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_8)*Point)){modify_sl_sell(Magic_8,tral_8);}}}
//+--------
 if((LevelSC_12==true)&&(avtomatic==true)){double ClosE_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,2,0);if(ClosE_12>1000)ClosE_12=0;
 double SignalBUY_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,3,0);if(SignalBUY_12>1000)SignalBUY_12=0;
 double SignalSELL_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,4,0);if(SignalSELL_12>1000)SignalSELL_12=0;
 double TP_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,6,0);if(TP_12>1000)TP_12=0;
 double SL_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,7,0);if(SL_12>1000)SL_12=0;
 if((ClosE_12>0)&&(orders(OP_BUY,Magic_12)+orders(OP_SELL,Magic_12)>0)){ALLCloseBUY(Magic_12);ALLCloseSELL(Magic_12);}
 if((orders(OP_BUY,Magic_12)+orders(OP_SELL,Magic_12)==0)&&(SignalBUY_12==0)&&(SignalSELL_12==0))trade_12=0;
 if((orders(OP_BUY,Magic_12)+orders(OP_SELL,Magic_12)>0))trade_12=1;
 if((trade_12==0)&&(SignalBUY_12>0)&&(TP_12>0)&&(SL_12>0)&&(orders(OP_BUY,Magic_12)==0)){Send_buy(SL_12,TP_12,Magic_12);}
 if((trade_12==0)&&(SignalSELL_12>0)&&(TP_12>0)&&(SL_12>0)&&(orders(OP_SELL,Magic_12)==0)){Send_sell(SL_12,TP_12,Magic_12);}
 if(bezubitok_12==true){if((orders(OP_BUY,Magic_12)>0)&&(NormalizeDouble(OrderStopLosS(Magic_12),4)<NormalizeDouble(OrderOpenPricE(Magic_12),4))&&(Bid-OrderOpenPricE(Magic_12)>uroven_bezubitok_12*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_12*Point)){bezubitok_sl_buy(Magic_12,Profit_bezubitok_12);}
 if((orders(OP_SELL,Magic_12)>0)&&(NormalizeDouble(OrderStopLosS(Magic_12),4)>NormalizeDouble(OrderOpenPricE(Magic_12),4))&&(OrderOpenPricE(Magic_12)-Ask>uroven_bezubitok_12*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_12*Point)){bezubitok_sl_sell(Magic_12,Profit_bezubitok_12);}}
 if(tral_12==true){if((orders(OP_BUY,Magic_12)>0)&&(Bid-OrderOpenPricE(Magic_12)>tral_12*Point)&&(Bid-OrderStopLosS(Magic_8)>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_12)*Point)){modify_sl_buy(Magic_12,tral_12);}
 if((orders(OP_SELL,Magic_12)>0)&&(OrderOpenPricE(Magic_12)-Ask>tral_12*Point)&&(OrderStopLosS(Magic_12)-Ask>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_12)*Point)){modify_sl_sell(Magic_12,tral_12);}}}
//+-------- 
 if((LevelSC_8==true)&&(avtomatic==false)){ClosE_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,2,0);if(ClosE_8>1000)ClosE_8=0;
 SignalBUY_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,3,0);if(SignalBUY_8>1000)SignalBUY_8=0;
 SignalSELL_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,4,0);if(SignalSELL_8>1000)SignalSELL_8=0;
 TP_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,6,0);if(TP_8>1000)TP_8=0;
 SL_8=iCustom(NULL,0,"Indikator 8  for LEVITAS  v.1.0",Hours2Check_8,CloseHour_8,EarliestOpenHour_8,Days2Check_8,ChannelK_8,CheckHour_8,ProfitK_8,LossK_8,OffsetK_8,7,0);if(SL_8>1000)SL_8=0; 
 if((Hour()==CloseHour)&&(orders(OP_BUY,Magic_8)+orders(OP_SELL,Magic_8)>0)){ALLCloseBUY(Magic_8);ALLCloseSELL(Magic_8);}
 if((orders(OP_BUY,Magic_8)+orders(OP_SELL,Magic_8)==0)&&(SignalBUY_8==0)&&(SignalSELL_8==0))trade_8=0;
 if((orders(OP_BUY,Magic_8)+orders(OP_SELL,Magic_8)>0))trade_8=1; 
 if((trade_8==0)&&(SignalBUY_8>0)&&(TP_8>0)&&(SL_8>0)&&(orders(OP_BUY,Magic_8)==0)){Send_buy2(Magic_8);}
 if((trade_8==0)&&(SignalSELL_8>0)&&(TP_8>0)&&(SL_8>0)&&(orders(OP_SELL,Magic_8)==0)){Send_sell2(Magic_8);}
 if(bezubitok_8==true){if((orders(OP_BUY,Magic_8)>0)&&(NormalizeDouble(OrderStopLosS(Magic_8),4)<NormalizeDouble(OrderOpenPricE(Magic_8),4))&&(Bid-OrderOpenPricE(Magic_8)>uroven_bezubitok_8*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_8*Point)){bezubitok_sl_buy(Magic_8,Profit_bezubitok_8);}
 if((orders(OP_SELL,Magic_8)>0)&&(NormalizeDouble(OrderStopLosS(Magic_8),4)>NormalizeDouble(OrderOpenPricE(Magic_8),4))&&(OrderOpenPricE(Magic_8)-Ask>uroven_bezubitok_8*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_8*Point)){bezubitok_sl_sell(Magic_8,Profit_bezubitok_8);}}
 if(tral_8==true){if((orders(OP_BUY,Magic_8)>0)&&(Bid-OrderOpenPricE(Magic_8)>tral_8*Point)&&(Bid-OrderStopLosS(Magic_8)>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_8)*Point)){modify_sl_buy(Magic_8,tral_8);}
 if((orders(OP_SELL,Magic_8)>0)&&(OrderOpenPricE(Magic_8)-Ask>tral_8*Point)&&(OrderStopLosS(Magic_8)-Ask>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_8)*Point)){modify_sl_sell(Magic_8,tral_8);}}}
//+--------
 if((LevelSC_12==true)&&(avtomatic==false)){ClosE_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,2,0);if(ClosE_12>1000)ClosE_12=0;
 SignalBUY_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,3,0);if(SignalBUY_12>1000)SignalBUY_12=0;
 SignalSELL_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,4,0);if(SignalSELL_12>1000)SignalSELL_12=0;
 TP_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,6,0);if(TP_12>1000)TP_12=0;
 SL_12=iCustom(NULL,0,"Indikator 12 for LEVITAS  v.1.0",Hours2Check_12,CloseHour_12,EarliestOpenHour_12,Days2Check_12,ChannelK_12,CheckHour_12,ProfitK_12,LossK_12,OffsetK_12,7,0);if(SL_12>1000)SL_12=0;
 if((Hour()==CloseHour)&&(orders(OP_BUY,Magic_12)+orders(OP_SELL,Magic_12)>0)){ALLCloseBUY(Magic_12);ALLCloseSELL(Magic_12);}
 if((orders(OP_BUY,Magic_12)+orders(OP_SELL,Magic_12)==0)&&(SignalBUY_12==0)&&(SignalSELL_12==0))trade_12=0;
 if((orders(OP_BUY,Magic_12)+orders(OP_SELL,Magic_12)>0))trade_12=1;
 if((trade_12==0)&&(SignalBUY_12>0)&&(TP_12>0)&&(SL_12>0)&&(orders(OP_BUY,Magic_12)==0)){Send_buy2(Magic_12);}
 if((trade_12==0)&&(SignalSELL_12>0)&&(TP_12>0)&&(SL_12>0)&&(orders(OP_SELL,Magic_12)==0)){Send_sell2(Magic_12);}
 if(bezubitok_12==true){if((orders(OP_BUY,Magic_12)>0)&&(NormalizeDouble(OrderStopLosS(Magic_12),4)<NormalizeDouble(OrderOpenPricE(Magic_12),4))&&(Bid-OrderOpenPricE(Magic_12)>uroven_bezubitok_12*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_12*Point)){bezubitok_sl_buy(Magic_12,Profit_bezubitok_12);}
 if((orders(OP_SELL,Magic_12)>0)&&(NormalizeDouble(OrderStopLosS(Magic_12),4)>NormalizeDouble(OrderOpenPricE(Magic_12),4))&&(OrderOpenPricE(Magic_12)-Ask>uroven_bezubitok_12*Point+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Profit_bezubitok_12*Point)){bezubitok_sl_sell(Magic_12,Profit_bezubitok_12);}}
 if(tral_12==true){if((orders(OP_BUY,Magic_12)>0)&&(Bid-OrderOpenPricE(Magic_12)>tral_12*Point)&&(Bid-OrderStopLosS(Magic_8)>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_12)*Point)){modify_sl_buy(Magic_12,tral_12);}
 if((orders(OP_SELL,Magic_12)>0)&&(OrderOpenPricE(Magic_12)-Ask>tral_12*Point)&&(OrderStopLosS(Magic_12)-Ask>(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+uroven_tral_12)*Point)){modify_sl_sell(Magic_12,tral_12);}}}
 }
//+------------------------------------------------------------------+