//+------------------------------------------------------------------+
//|                                              Inf_Open_Orders.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Сергей"
#include <stdlib.mqh>
#property indicator_chart_window
//----
extern string    Symbol.1="GBPJPY";
extern string    Symbol.2="USDCHF";
extern string    Symbol.3="EURUSD";
extern string    Symbol.4="EURGBP";
extern string    Symbol.5="GBPUSD";
extern string    Symbol.6="EURCHF";
extern string    Symbol.7="EURJPY";
extern string    Symbol.8="GPBPCHF";
extern string    Symbol.9="AUDJPY";
extern string    Symbol.10="AUDUSD";
extern string    Symbol.11="NZDUSD";
extern string    Symbol.12="NZDJPY";
extern string    Symbol.13="CHFJPY";
extern string    Symbol.14="USDCHF";
//----
extern int       ОкноПривязки=0;
extern int       X=0;
extern int       Y=5;
extern int       УголПривязки=3;
extern int       РазмерШрифта=10;
//----
double LotS,ProfitS;
double LotB,ProfitB;
double LotT,ProfitT;
double ProfitHistory;
double PartEquity;
color Color;
int  pos,orderremit,TotalOrders,Symb;
string text;
int File;
string FileName;
int CountDate;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//----
       ObjectCreate("Inf_Buy", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSetText("Inf_Buy","BUY  lot=           ; profit=",РазмерШрифта,"Arial",Chartreuse);
       ObjectSet("Inf_Buy",OBJPROP_XDISTANCE,X+7*РазмерШрифта);
       ObjectSet("Inf_Buy",OBJPROP_YDISTANCE,Y+5.1*РазмерШрифта);
       ObjectSet("Inf_Buy",OBJPROP_CORNER,УголПривязки);
        
       ObjectCreate("Inf_BuyLots", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSet("Inf_BuyLots",OBJPROP_XDISTANCE,X+11.5*РазмерШрифта);
       ObjectSet("Inf_BuyLots",OBJPROP_YDISTANCE,Y+5.1*РазмерШрифта);
       ObjectSet("Inf_BuyLots",OBJPROP_CORNER,УголПривязки);
       
       ObjectCreate("Inf_BuyProfit", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSet("Inf_BuyProfit",OBJPROP_XDISTANCE,X+0.5*РазмерШрифта);
       ObjectSet("Inf_BuyProfit",OBJPROP_YDISTANCE,Y+5.1*РазмерШрифта);
       ObjectSet("Inf_BuyProfit",OBJPROP_CORNER,УголПривязки);      
//---- 
       ObjectCreate("Inf_Sell", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSetText("Inf_Sell","SELL  lot=           ; profit=",РазмерШрифта,"Arial",DeepPink);
       ObjectSet("Inf_Sell",OBJPROP_XDISTANCE,X+7*РазмерШрифта);
       ObjectSet("Inf_Sell",OBJPROP_YDISTANCE,Y+3.4*РазмерШрифта);
       ObjectSet("Inf_Sell",OBJPROP_CORNER,УголПривязки);
         
       ObjectCreate("Inf_SellLots", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSet("Inf_SellLots",OBJPROP_XDISTANCE,X+11.5*РазмерШрифта);
       ObjectSet("Inf_SellLots",OBJPROP_YDISTANCE,Y+3.4*РазмерШрифта);
       ObjectSet("Inf_SellLots",OBJPROP_CORNER,УголПривязки);
        
       ObjectCreate("Inf_SellProfit", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSet("Inf_SellProfit",OBJPROP_XDISTANCE,X+0.5*РазмерШрифта);
       ObjectSet("Inf_SellProfit",OBJPROP_YDISTANCE,Y+3.4*РазмерШрифта);
       ObjectSet("Inf_SellProfit",OBJPROP_CORNER,УголПривязки);      
//----
       ObjectCreate("Inf_Total", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSetText("Inf_Total","Total  lot=           ; profit=",РазмерШрифта,"Arial",Gold);
       ObjectSet("Inf_Total",OBJPROP_XDISTANCE,X+7*РазмерШрифта);
       ObjectSet("Inf_Total",OBJPROP_YDISTANCE,Y+1.7*РазмерШрифта);
       ObjectSet("Inf_Total",OBJPROP_CORNER,УголПривязки); 
       
       ObjectCreate("Inf_TotalLots", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSet("Inf_TotalLots",OBJPROP_XDISTANCE,X+11.5*РазмерШрифта);
       ObjectSet("Inf_TotalLots",OBJPROP_YDISTANCE,Y+1.7*РазмерШрифта);
       ObjectSet("Inf_TotalLots",OBJPROP_CORNER,УголПривязки); 
       
       ObjectCreate("Inf_TotalProfit", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSet("Inf_TotalProfit",OBJPROP_XDISTANCE,X+0.5*РазмерШрифта);
       ObjectSet("Inf_TotalProfit",OBJPROP_YDISTANCE,Y+1.7*РазмерШрифта);
       ObjectSet("Inf_TotalProfit",OBJPROP_CORNER,УголПривязки);
//----
  FileName="Inf_Open_Orders_"+Symbol()+".csv";
  File=FileOpen(FileName,FILE_CSV|FILE_READ|FILE_WRITE,';');
  if(File>0)
    {
    CountDate=FileReadNumber(File);
    FileClose(File);
    }
  else if(File<1)
    {
    Alert("File Inf_Open_Orders_",Symbol(),".csv не обнаружен, последняя ошибка ", GetLastError());
    }

       ObjectCreate("Inf_HistoryTotal", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSetText("Inf_HistoryTotal","Total History profit ("+TimeToStr(CountDate,TIME_DATE)+")=",РазмерШрифта,"Arial",DarkOrange);
       ObjectSet("Inf_HistoryTotal",OBJPROP_XDISTANCE,X+7*РазмерШрифта);
       ObjectSet("Inf_HistoryTotal",OBJPROP_YDISTANCE,Y);
       ObjectSet("Inf_HistoryTotal",OBJPROP_CORNER,УголПривязки); 
       
       ObjectCreate("Inf_HistoryTotalProfit", OBJ_LABEL,ОкноПривязки,0,0);
       ObjectSet("Inf_HistoryTotalProfit",OBJPROP_XDISTANCE,X+0.5*РазмерШрифта);
       ObjectSet("Inf_HistoryTotalProfit",OBJPROP_YDISTANCE,Y);
       ObjectSet("Inf_HistoryTotalProfit",OBJPROP_CORNER,УголПривязки);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
    ObjectDelete("Inf_Buy");
    ObjectDelete("Inf_BuyLots");
    ObjectDelete("Inf_BuyProfit");
    ObjectDelete("Inf_Sell");
    ObjectDelete("Inf_SellLots");
    ObjectDelete("Inf_SellProfit");
    ObjectDelete("Inf_Total");
    ObjectDelete("Inf_TotalLots"); 
    ObjectDelete("Inf_TotalProfit");
    ObjectDelete("Inf_HistoryTotal");
    ObjectDelete("Inf_HistoryTotalProfit");     
//----
    for(pos=100;pos>0;pos--)
      {
      ObjectDelete("OrderRemitPrise #"+pos);
      ObjectDelete("OrderRemitLot #"+pos); 
      }
//----
    ObjectDelete("Line of the history zero price"); 
    ObjectDelete("History zero price");
    
    ObjectDelete("Line of the zero price"); 
    ObjectDelete("Zero price");
    
    ObjectDelete("Line of the BUY zero price"); 
    ObjectDelete("BUY Zero price");
    
    ObjectDelete("Line of the SELL zero price"); 
    ObjectDelete("SELL Zero price");
    
    ObjectDelete("Line of the StopOut price"); 
    ObjectDelete("StopOut price");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
  if(AccountBalance()==0)return(0);
//----
double TickVal=MarketInfo(Symbol(), MODE_TICKVALUE);
//---- определение количества инструментов и распределение средств для них
    
//---- выставление уровня маржинкола

  if(TotalOrders!=OrdersTotal() && AccountBalance()!=0)
    {
    TotalOrders=OrdersTotal();
    double Lot,Lot.1,Lot.2,Lot.3,Lot.4,Lot.5,Lot.6,Lot.7,Lot.8,Lot.9,Lot.10;
    for(pos=OrdersTotal()-1;pos>=0;pos--)
      {
      if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true)
        {
        if(OrderType()<=OP_SELL)
          {
          if(OrderType()==OP_BUY){Lot=OrderLots();}
          if(OrderType()==OP_SELL){Lot=-OrderLots();}
          if(OrderSymbol()==Symbol.1){Lot.1=NormalizeDouble(Lot.1+Lot,2);} 
          else if(OrderSymbol()==Symbol.2){Lot.2=NormalizeDouble(Lot.2+Lot,2);} 
          else if(OrderSymbol()==Symbol.3){Lot.3=NormalizeDouble(Lot.3+Lot,2);} 
          else if(OrderSymbol()==Symbol.4){Lot.4=NormalizeDouble(Lot.4+Lot,2);} 
          else if(OrderSymbol()==Symbol.5){Lot.5=NormalizeDouble(Lot.5+Lot,2);} 
          else if(OrderSymbol()==Symbol.6){Lot.6=NormalizeDouble(Lot.6+Lot,2);} 
          else if(OrderSymbol()==Symbol.7){Lot.7=NormalizeDouble(Lot.7+Lot,2);} 
          else if(OrderSymbol()==Symbol.8){Lot.8=NormalizeDouble(Lot.8+Lot,2);} 
          else if(OrderSymbol()==Symbol.9){Lot.9=NormalizeDouble(Lot.9+Lot,2);} 
          else if(OrderSymbol()==Symbol.10){Lot.10=NormalizeDouble(Lot.10+Lot,2);} 
          else 
            {
            Alert("\"Inf_Open_Orders\". Появился ордер по неуказанному инструменту ",OrderSymbol(),"!");
            return(0);
            }
          }      
        }
      else Print("Ошибка ",GetLastError());
      }
    Symb=0;
    if(Lot.1!=0){Symb++;}
    if(Lot.2!=0){Symb++;}
    if(Lot.3!=0){Symb++;}
    if(Lot.4!=0){Symb++;}
    if(Lot.5!=0){Symb++;}
    if(Lot.6!=0){Symb++;}
    if(Lot.7!=0){Symb++;}
    if(Lot.8!=0){Symb++;}
    if(Lot.9!=0){Symb++;}
    if(Lot.10!=0){Symb++;}
    }
  if(Symb!=0)
    {
    PartEquity=(AccountEquity()-AccountStopoutLevel()/100*AccountMargin())/Symb;//распределённые средства
    }
    
//---- определение профитов и обьёмов лотов
  LotS=0;
  ProfitS=0;
  LotB=0;
  ProfitB=0;
  ProfitT=0;

  for(pos=OrdersTotal()-1; pos>=0; pos--)
    {
    if(OrderSelect(pos, SELECT_BY_POS, MODE_TRADES) == true)
      {
      if(OrderSymbol()==Symbol())
        {
      //----
        if(OrderType() == OP_BUY)
          {
          LotB += OrderLots();
          ProfitB+=OrderProfit()+OrderSwap();
          }
      //----
        if(OrderType() == OP_SELL)
          {
          LotS += OrderLots();
          ProfitS+=OrderProfit()+OrderSwap(); 
          }
      //----
        ProfitT+=OrderProfit()+OrderSwap();
      //----
        }               
      }
    else Print("Ошибка при доступе к реал базе (",GetLastError(),")");
    }
     
//---- определение начала отсчёта в истории ордеров
  if(AccountBalance()!=0)
  //----
    {
    int order;
    for(pos=OrdersTotal()-1;pos>=0;pos--)//поиск наличия открытых ордеров
      {
      if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true)
        {
        if(OrderSymbol()==Symbol() && OrderType()<=OP_SELL)
          {
          order++;             
          }
        }
      else Print("Ошибка при доступе к реал базе (",GetLastError(),")");
      }
      
    if(order==0)// при отсутствии открытых ордеров устанавливаеться дата осчёта тотального профита
      {
      CountDate=TimeCurrent();
      File=FileOpen(FileName,FILE_CSV|FILE_WRITE,';');//открытие Fileа для сохранения даты отсчёта
      if(File>0)
        {
        FileWrite(File,CountDate);
        FileClose(File);
        }
      else if(File<1)
        {
        Alert("File ",FileName," не обнаружен, последняя ошибка ", GetLastError());
        }
      }  
    }
//----
  string text=StringConcatenate("Total History profit (",TimeToStr(CountDate,TIME_DATE|TIME_MINUTES),")="); 
  ObjectSetText("Inf_HistoryTotal",text,РазмерШрифта,"Arial",DarkOrange);
//----  
  ProfitHistory=0;
  for(pos=OrdersHistoryTotal()-1;pos>=0;pos--)//подсчёт профита из истории
    {
    if(OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY)==true)
      {
      if(OrderSymbol()==Symbol() && OrderOpenTime()>=CountDate)
        {
        ProfitHistory+=OrderProfit()+OrderSwap();             
        }
      }
    else Print("Ошибка при доступе к исторической базе (",GetLastError(),")");
    }
  ProfitHistory=ProfitHistory+ProfitT;  
    
//---- выставление нулевых и StopOut уровней  
  LotT=LotB-LotS;
  if(LotT!=0)
    {
    double HistoryZeroPrice,ZeroPrice,StopOutPrice;
    if(LotT>0)//Buy лот прeимущество
      {
      HistoryZeroPrice=NormalizeDouble(Bid-(ProfitHistory/LotT/TickVal*Point),Digits);
      ZeroPrice=NormalizeDouble(Bid-(ProfitT/LotT/TickVal*Point),Digits);
      StopOutPrice=NormalizeDouble(Bid-(PartEquity/LotT/TickVal*Point),Digits);
      }
    if(LotT<0)//Sell лот прeимущество
      {
      HistoryZeroPrice=NormalizeDouble(Ask-(ProfitHistory/LotT/TickVal*Point),Digits);
      ZeroPrice=NormalizeDouble(Ask-(ProfitT/LotT/TickVal*Point),Digits);
      StopOutPrice=NormalizeDouble(Ask-(PartEquity/LotT/TickVal*Point),Digits);
      }
      
  //---- Выставление общего исторического нулевого уровня
    if(ObjectFind("Line of the zero price")!=0)//отсутствие Line zero в главном окне
      {
      ObjectCreate("Line of the history zero price",OBJ_TREND,0,Time[5],HistoryZeroPrice,Time[0]+Period()*60*20,HistoryZeroPrice,0,0);
      ObjectSetText("Line of the history zero price",DoubleToStr(HistoryZeroPrice,Digits)); 
      ObjectSet("Line of the history zero price",OBJPROP_RAY,false);
      ObjectSet("Line of the history zero price",OBJPROP_STYLE,STYLE_SOLID); 
      ObjectSet("Line of the history zero price",OBJPROP_WIDTH,1);
      ObjectSet("Line of the history zero price",OBJPROP_COLOR,DarkOrange);
      }
    else if(ObjectFind("Line of the history zero price")==0)//наличие Line zero в главном окне
      {
      ObjectSetText("Line of the history zero price",DoubleToStr(HistoryZeroPrice,Digits)); 
      ObjectSet("Line of the history zero price",OBJPROP_TIME1,Time[5]);
      ObjectSet("Line of the history zero price",OBJPROP_PRICE1,HistoryZeroPrice);
      ObjectSet("Line of the history zero price",OBJPROP_TIME2,Time[0]+Period()*60*20);
      ObjectSet("Line of the history zero price",OBJPROP_PRICE2,HistoryZeroPrice);
      }
    if(ObjectFind("History zero price")!=0)//отсутствие Arrow zero в главном окне
      {
      ObjectCreate("History zero price",OBJ_ARROW,0,Time[5],HistoryZeroPrice,0,0,0,0);
      ObjectSet("History zero price",OBJPROP_ARROWCODE,5); 
      ObjectSet("History zero price",OBJPROP_WIDTH,2);
      ObjectSet("History zero price",OBJPROP_COLOR,DarkOrange);    
      }
    else if(ObjectFind("History zero price")==0)//наличие Arrow zero в главном окне 
      {
      ObjectSet("History zero price",OBJPROP_PRICE1,HistoryZeroPrice);
      ObjectSet("History zero price",OBJPROP_TIME1,Time[5]);
      }
      
  //---- Выставление общего нулевого реал уровня
    if(ObjectFind("Line of the zero price")!=0)//отсутствие Line zero в главном окне
      {
      ObjectCreate("Line of the zero price",OBJ_TREND,0,Time[5],ZeroPrice,Time[0]+Period()*60*20,ZeroPrice,0,0);
      ObjectSetText("Line of the zero price",DoubleToStr(ZeroPrice,Digits)); 
      ObjectSet("Line of the zero price",OBJPROP_RAY,false);
      ObjectSet("Line of the zero price",OBJPROP_STYLE,STYLE_SOLID); 
      ObjectSet("Line of the zero price",OBJPROP_WIDTH,1);
      ObjectSet("Line of the zero price",OBJPROP_COLOR,Gold);
      }
    else if(ObjectFind("Line of the zero price")==0)//наличие Line zero в главном окне
      {
      ObjectSetText("Line of the zero price",DoubleToStr(ZeroPrice,Digits)); 
      ObjectSet("Line of the zero price",OBJPROP_TIME1,Time[5]);
      ObjectSet("Line of the zero price",OBJPROP_PRICE1,ZeroPrice);
      ObjectSet("Line of the zero price",OBJPROP_TIME2,Time[0]+Period()*60*20);
      ObjectSet("Line of the zero price",OBJPROP_PRICE2,ZeroPrice);
      }
    if(ObjectFind("Zero price")!=0)//отсутствие Arrow zero в главном окне
      {
      ObjectCreate("Zero price",OBJ_ARROW,0,Time[5],ZeroPrice,0,0,0,0);
      ObjectSet("Zero price",OBJPROP_ARROWCODE,5); 
      ObjectSet("Zero price",OBJPROP_WIDTH,2);
      ObjectSet("Zero price",OBJPROP_COLOR,Gold);    
      }
    else if(ObjectFind("Zero price")==0)//наличие Arrow zero в главном окне 
      {
      ObjectSet("Zero price",OBJPROP_PRICE1,ZeroPrice);
      ObjectSet("Zero price",OBJPROP_TIME1,Time[5]);
      }
      
  //---- Выставление StopOut уровня  
    if(ObjectFind("Line of the StopOut price")!=0)
      {
      ObjectCreate("Line of the StopOut price",OBJ_TREND,0,Time[5],StopOutPrice,Time[0]+Period()*60*20,StopOutPrice,0,0);
      ObjectSetText("Line of the StopOut price",DoubleToStr(StopOutPrice,Digits)); 
      ObjectSet("Line of the StopOut price",OBJPROP_RAY,false);
      ObjectSet("Line of the StopOut price",OBJPROP_STYLE,STYLE_SOLID); 
      ObjectSet("Line of the StopOut price",OBJPROP_WIDTH,2);
      ObjectSet("Line of the StopOut price",OBJPROP_COLOR,Brown);
      }
    else if(ObjectFind("Line of the StopOut price")==0) 
      {
      ObjectSetText("Line of the StopOut price",DoubleToStr(StopOutPrice,Digits)); 
      ObjectSet("Line of the StopOut price",OBJPROP_TIME1,Time[5]);
      ObjectSet("Line of the StopOut price",OBJPROP_PRICE1,StopOutPrice);
      ObjectSet("Line of the StopOut price",OBJPROP_TIME2,Time[0]+Period()*60*20);
      ObjectSet("Line of the StopOut price",OBJPROP_PRICE2,StopOutPrice);
      }
    if(ObjectFind("StopOut price")!=0)
      {
      ObjectCreate("StopOut price",OBJ_ARROW,0,Time[5],StopOutPrice,0,0,0,0);
      ObjectSet("StopOut price",OBJPROP_ARROWCODE,5); 
      ObjectSet("StopOut price",OBJPROP_WIDTH,3);
      ObjectSet("StopOut price",OBJPROP_COLOR,Brown);    
      }
    else if(ObjectFind("StopOut price")==0) 
      {
      ObjectSet("StopOut price",OBJPROP_PRICE1,StopOutPrice);
      ObjectSet("StopOut price",OBJPROP_TIME1,Time[5]);
      }
  //----
    }
  else if(LotT==0)
    {
    if(ObjectFind("Line of the history zero price")==0)ObjectDelete("Line of the history zero price"); 
    if(ObjectFind("History zero price")==0)ObjectDelete("History zero price"); 
    if(ObjectFind("Line of the zero price")==0)ObjectDelete("Line of the zero price"); 
    if(ObjectFind("Zero price")==0)ObjectDelete("Zero price"); 
    if(ObjectFind("Line of the StopOut price")==0)ObjectDelete("Line of the StopOut price"); 
    if(ObjectFind("StopOut price")==0)ObjectDelete("StopOut price");
    }

  //---- Выставление BUY нулевого уровня 
  if(LotB>0)
    {
    double BUYZeroPrice;
    BUYZeroPrice=NormalizeDouble(Bid-(ProfitB/LotB/TickVal*Point),Digits);
    if(ObjectFind("Line of the BUY zero price")!=0)
      {
      ObjectCreate("Line of the BUY zero price",OBJ_TREND,0,Time[5],BUYZeroPrice,Time[0]+Period()*60*20,BUYZeroPrice,0,0);
      ObjectSetText("Line of the BUY zero price",DoubleToStr(BUYZeroPrice,Digits)); 
      ObjectSet("Line of the BUY zero price",OBJPROP_RAY,false);
      ObjectSet("Line of the BUY zero price",OBJPROP_STYLE,STYLE_SOLID); 
      ObjectSet("Line of the BUY zero price",OBJPROP_WIDTH,1);
      ObjectSet("Line of the BUY zero price",OBJPROP_COLOR,Chartreuse);
      }
    else if(ObjectFind("Line of the BUY zero price")==0) 
      {
      ObjectSetText("Line of the BUY zero price",DoubleToStr(BUYZeroPrice,Digits)); 
      ObjectSet("Line of the BUY zero price",OBJPROP_TIME1,Time[5]);
      ObjectSet("Line of the BUY zero price",OBJPROP_PRICE1,BUYZeroPrice);
      ObjectSet("Line of the BUY zero price",OBJPROP_TIME2,Time[0]+Period()*60*20);
      ObjectSet("Line of the BUY zero price",OBJPROP_PRICE2,BUYZeroPrice);
      }
    if(ObjectFind("BUY Zero price")!=0)
      {
      ObjectCreate("BUY Zero price",OBJ_ARROW,0,Time[5],BUYZeroPrice,0,0,0,0);
      ObjectSet("BUY Zero price",OBJPROP_ARROWCODE,5); 
      ObjectSet("BUY Zero price",OBJPROP_WIDTH,2);
      ObjectSet("BUY Zero price",OBJPROP_COLOR,Chartreuse);    
      }
    else if(ObjectFind("BUY Zero price")==0) 
      {
      ObjectSet("BUY Zero price",OBJPROP_PRICE1,BUYZeroPrice);
      ObjectSet("BUY Zero price",OBJPROP_TIME1,Time[5]);
      }
    }
  else if(LotB==0)
    {
    if(ObjectFind("Line of the BUY zero price")==0)ObjectDelete("Line of the BUY zero price"); 
    if(ObjectFind("BUY Zero price")==0)ObjectDelete("BUY Zero price");
    }
      
  //---- Выставление SELL нулевого уровня 
  if(LotS>0)
    {
    double SELLZeroPrice;
    SELLZeroPrice=NormalizeDouble(Ask+(ProfitS/LotS/TickVal*Point),Digits);
    if(ObjectFind("Line of the SELL zero price")!=0)
      {
      ObjectCreate("Line of the SELL zero price",OBJ_TREND,0,Time[5],SELLZeroPrice,Time[0]+Period()*60*20,SELLZeroPrice,0,0);
      ObjectSetText("Line of the SELL zero price",DoubleToStr(SELLZeroPrice,Digits)); 
      ObjectSet("Line of the SELL zero price",OBJPROP_RAY,false);
      ObjectSet("Line of the SELL zero price",OBJPROP_STYLE,STYLE_SOLID); 
      ObjectSet("Line of the SELL zero price",OBJPROP_WIDTH,1);
      ObjectSet("Line of the SELL zero price",OBJPROP_COLOR,DeepPink);
      }
    else if(ObjectFind("Line of the SELL zero price")==0) 
      {
      ObjectSetText("Line of the SELL zero price",DoubleToStr(SELLZeroPrice,Digits)); 
      ObjectSet("Line of the SELL zero price",OBJPROP_TIME1,Time[5]);
      ObjectSet("Line of the SELL zero price",OBJPROP_PRICE1,SELLZeroPrice);
      ObjectSet("Line of the SELL zero price",OBJPROP_TIME2,Time[0]+Period()*60*20);
      ObjectSet("Line of the SELL zero price",OBJPROP_PRICE2,SELLZeroPrice);
      }
    if(ObjectFind("SELL Zero price")!=0)
      {
      ObjectCreate("SELL Zero price",OBJ_ARROW,0,Time[5],SELLZeroPrice,0,0,0,0);
      ObjectSet("SELL Zero price",OBJPROP_ARROWCODE,5); 
      ObjectSet("SELL Zero price",OBJPROP_WIDTH,2);
      ObjectSet("SELL Zero price",OBJPROP_COLOR,DeepPink);    
      }
    else if(ObjectFind("SELL Zero price")==0) 
      {
      ObjectSet("SELL Zero price",OBJPROP_PRICE1,SELLZeroPrice);
      ObjectSet("SELL Zero price",OBJPROP_TIME1,Time[5]);
      }
    }
  else if(LotS==0)
    {
    if(ObjectFind("Line of the SELL zero price")==0)ObjectDelete("Line of the SELL zero price"); 
    if(ObjectFind("SELL Zero price")==0)ObjectDelete("SELL Zero price");
    }

//---- заполнение строк информацией
  ProfitB=NormalizeDouble(ProfitB,0);
  ProfitS=NormalizeDouble(ProfitS,0);
  ProfitHistory=NormalizeDouble(ProfitHistory,0);
   //строка Buy
       if(LotB>0)
         {
         text=DoubleToStr(LotB,2);
         }
       else if(LotB==0){text="";}
       ObjectSetText("Inf_BuyLots",text,РазмерШрифта,"Arial",Aqua);
       if(LotB>0)
         {
         if(ProfitB<0)Color=Red;
         if(ProfitB>0)Color=Green;
         if(ProfitB==0)Color=Gold;
         text=DoubleToStr(ProfitB,0);
         }
       else if(LotB==0){text="";}
       ObjectSetText("Inf_BuyProfit",text,РазмерШрифта,"Arial",Color);
   //строка Sell       
       if(LotS>0)
         {
         text=DoubleToStr(LotS,2);
         }
       else if(LotS==0){text="";}
       ObjectSetText("Inf_SellLots",text,РазмерШрифта,"Arial",OrangeRed);
       if(LotS>0)
         {
         if(ProfitS<0)Color=Red;
         if(ProfitS>0)Color=Green;
         if(ProfitS==0)Color=Gold;
         text=DoubleToStr(ProfitS,0);
         }
       else if(LotS==0){text="";}
       ObjectSetText("Inf_SellProfit",text,РазмерШрифта,"Arial",Color);
   //строка тотал
       if(LotS>0 || LotB>0)
         {
         LotT=NormalizeDouble(LotB-LotS,2);
         if(LotT<0)Color=OrangeRed;
         if(LotT>0)Color=Aqua;
         if(LotT==0)Color=Gold;
         text=DoubleToStr(LotT,2);
         }
       else if(LotS==0 && LotB==0){text="";}
       ObjectSetText("Inf_TotalLots",text,РазмерШрифта,"Arial",Color);
       if(LotS>0 || LotB>0)
         {
         if(ProfitB+ProfitS<0)Color=Red;
         if(ProfitB+ProfitS>0)Color=Green;
         if(ProfitB+ProfitS==0)Color=Gold;
         text=DoubleToStr(ProfitB+ProfitS,0);
         }
       else if(LotS==0 && LotB==0){text="";}
       ObjectSetText("Inf_TotalProfit",text,РазмерШрифта,"Arial",Color);
   //строка History тотал
       if(LotS>0 || LotB>0)
         {
         if(ProfitHistory<0)Color=Red;
         if(ProfitHistory>0)Color=Green;
         if(ProfitHistory==0)Color=Gold;
         text=DoubleToStr(ProfitHistory,0);
         }
       else if(LotS==0 && LotB==0){text="";}
       ObjectSetText("Inf_HistoryTotalProfit",text,РазмерШрифта,"Arial",Color);

//---- Выставление уровней отложенных ордеров
  int OrderRemit;
  for(pos=OrdersTotal()-1;pos>=0;pos--)
    {
    if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true)
      {
      if(OrderSymbol()==Symbol() && OrderType()>=OP_BUYLIMIT)
        {
        OrderRemit++;
        if(ObjectFind("OrderRemitPrise #"+OrderRemit)==0)
          {
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_TIME2,Time[0]+Period()*60*20); 
          }
        if(ObjectFind("OrderRemitLot #"+OrderRemit)==0)
          {
          ObjectSet("OrderRemitLot #"+OrderRemit,OBJPROP_TIME2,Time[0]+Period()*60*20); 
          }
        }
      }
    else Print("Выбор ордера! Ошибка ",GetLastError());
    }
  if(orderremit!=OrderRemit)
    {
    orderremit=OrderRemit;
    for(pos=100;pos>0;pos--)
      {
      ObjectDelete("OrderRemitPrise #"+pos);
      ObjectDelete("OrderRemitLot #"+pos); 
      }
    }
//----
  for(pos=OrdersTotal()-1;pos>=0;pos--)
    {
    if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true)
      {
      if(OrderSymbol()==Symbol() && OrderRemit>0 && OrderType()>=OP_BUYLIMIT)
        {
        if(OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP){Color=Aqua;}
        if(OrderType()==OP_SELLLIMIT || OrderType()==OP_SELLSTOP){Color=OrangeRed;}
      //----
        if(ObjectFind("OrderRemitPrise #"+OrderRemit)==-1)
          {
          ObjectCreate("OrderRemitPrise #"+OrderRemit,OBJ_TREND,0,
                       OrderOpenTime()-Period()*60*5,OrderOpenPrice(),
                       Time[0]+Period()*60*20,OrderOpenPrice(),0,0); 
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_RAY,false);
          text=DoubleToStr(OrderOpenPrice(),Digits);
          ObjectSetText("OrderRemitPrise #"+OrderRemit,text);
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_COLOR,Color); 
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_WIDTH,1); 
          }
      //----
        if(ObjectGet("OrderRemitPrise #"+OrderRemit,OBJPROP_PRICE1)!=OrderOpenPrice() ||
           ObjectGet("OrderRemitPrise #"+OrderRemit,OBJPROP_PRICE2)!=OrderOpenPrice() ||
           ObjectGet("OrderRemitPrise #"+OrderRemit,OBJPROP_COLOR)!=Color)
          {
          Print("ObjectGet(OrderRemitPrise #+",OrderRemit,",OBJPROP_PRICE1)!=OrderOpenPrice()"); 
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_TIME1,OrderOpenTime()-Period()*60*5);
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_PRICE1,OrderOpenPrice());
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_TIME2,Time[0]+Period()*60*20); 
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_PRICE2,OrderOpenPrice());
          text=DoubleToStr(OrderOpenPrice(),Digits);
          ObjectSetText("OrderRemitPrise #"+OrderRemit,text);
          ObjectSet("OrderRemitPrise #"+OrderRemit,OBJPROP_COLOR,Color);
          }
      //----
        if(ObjectFind("OrderRemitLot #"+OrderRemit)==-1)
          {
          ObjectCreate("OrderRemitLot #"+OrderRemit,OBJ_TEXT,0,Time[0]+Period()*60*20,OrderOpenPrice(),0,0,0,0);
          text=StringConcatenate(DoubleToStr(OrderLots(),2)," (",DoubleToStr(OrderOpenPrice(),Digits),")");
          ObjectSetText("OrderRemitLot #"+OrderRemit,text,РазмерШрифта-1,"Arial",Color); 
          }
      //----
        if(ObjectGet("OrderRemitLot #"+OrderRemit,OBJPROP_PRICE1)!=OrderOpenPrice() ||
           ObjectGet("OrderRemitLot #"+OrderRemit,OBJPROP_COLOR)!=Color)
          {
          ObjectSet("OrderRemitLot #"+OrderRemit,OBJPROP_TIME1,Time[0]+Period()*60*20);
          ObjectSet("OrderRemitLot #"+OrderRemit,OBJPROP_PRICE1,OrderOpenPrice());
          text=StringConcatenate(DoubleToStr(OrderLots(),2)," (",DoubleToStr(OrderOpenPrice(),Digits),")");
          ObjectSetText("OrderRemitLot #"+OrderRemit,text,РазмерШрифта-1,"Arial",Color);
          }
      //----
        OrderRemit--;
        }
      }
    else Print("Выбор ордера! Ошибка ",GetLastError());
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+