#property indicator_chart_window
//+------------------------------------------------------------------+
bool Sound=false;
extern bool OrderLevel=false;
extern color prib=C'215,183,0';
extern color ubyt=C'191,0,0';
color zero=clrSnow;
color otloj=clrTurquoise;
color razdel=clrCoral;
color Fon=clrYellow;
//+------------------------------------------------------------------+
bool f=true; int ord; bool ind=false; bool his;
int or=0,ot=0;
int start(){
int OT=0;
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()>1)OT++;
}
if(OT<ot&&OrdersTotal()==or){if(Sound){PlaySound("ot.wav");index();}}ot=OT;
//+------------------------------------------------------------------+
history();
if(his==true)
return(0);
int tot=OrdersTotal();
if(tot>0){f=true;}
if(ind==true){ObjectDelete("djfhrkoc");ind=false;}
if(f==false)
return(0);
if(tot==0&&f==true)
{
open();
label();
f=false;
if(ord>tot)sound();
if(ord!=tot)del();
ord=tot;
return(0);
}
open();
if(ord>tot)sound();
if(ord!=tot)del();
ord=tot;
or=OrdersTotal();
return(0);
}

void open(){
int vertikal=3;
for(int z=0;z<OrdersTotal();z++)
{
OrderSelect(z,SELECT_BY_POS);
//+------------------------------------------------------------------+
double Profit=OrderProfit();
double proc=Profit/(AccountBalance()/100);
//+------------------------------------------------------------------+
double pips=MarketInfo(OrderSymbol(),MODE_POINT);
double stop=OrderStopLoss();
double price=OrderOpenPrice();
double pipss=MathAbs(price-stop)/pips;
double tickvalue=MarketInfo(OrderSymbol(),MODE_TICKVALUE);
if(Digits==5||Digits==3){pipss=pipss/10;tickvalue=tickvalue*10;}
double risk=tickvalue*OrderLots()*pipss/(AccountBalance()/100);
string rick=DoubleToStr(risk,2);
//+------------------------------------------------------------------+
color cvet=ubyt;
if(Profit>0)cvet=prib;
if(Profit==0)cvet=zero;
int type=OrderType();
//+------------------------------------------------------------------+
 if(type==0||type==2||type==4)
 {
   if(stop>price){string urst="+"+DoubleToStr((stop-price)/pips,0);}
   else
   {urst=" "+DoubleToStr((stop-price)/pips,0);}
 }
 if(type==1||type==3||type==5)
 {
   if(stop<price){urst="+"+DoubleToStr((price-stop)/pips,0);}
   else
   {urst=" "+DoubleToStr((price-stop)/pips,0);}
 }

if(type>1){cvet=otloj;}else if(OrderSymbol()==Symbol())line();
string TEXT=urst+"  ";

//+------------------------------------------------------------------+
double ask=MarketInfo(OrderSymbol(),MODE_ASK);
double bid=MarketInfo(OrderSymbol(),MODE_BID);
if(type<1){int punk=(bid-price)/pips/10;string punkty=DoubleToStr(punk,0);}
else {punk=(price-ask)/pips/10;punkty=DoubleToStr(punk,0);}
if(Profit>0)string k="+"; else k="";
switch(type)
{
case 0: TEXT="buy:  "+k+DoubleToStr(Profit,2)+" $ ("+k+punkty+") ";break;
case 1: TEXT="sell: "+k+DoubleToStr(Profit,2)+" $ ("+k+punkty+") ";break;
}

ObjectCreate("opens"+z,OBJ_LABEL,0,0,0);
ObjectSet("opens"+z, OBJPROP_CORNER, 0);
ObjectSet("opens"+z,OBJPROP_XDISTANCE,5);  
ObjectSet("opens"+z,OBJPROP_YDISTANCE,vertikal+11);
ObjectSetText("opens"+z,TEXT,17,"Nyala",cvet);

vertikal+=22;
}//+------------------------------------------------------------------+FOR
while(z<20){ObjectDelete("open"+z);ObjectDelete("opens"+z);ObjectDelete("opensr"+z);z++;}
return;}
void label(){
color cvt=MediumSeaGreen;
if(IsDemo())cvt=White;
switch(Period())
{
case 1: string tf="1 ìèíóòà";break;
}
return;}

void sound(){
int z=0,ticket;
double prof;
for(int i=0;i<OrdersHistoryTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
int oct=OrderCloseTime();
if(oct>z){z=oct;prof=OrderProfit();ticket=OrderTicket();}
}
OrderSelect(ticket,SELECT_BY_TICKET,MODE_HISTORY);
int dig=MarketInfo(OrderSymbol(),MODE_DIGITS);
if(Digits==3||Digits==5)dig--;
double ocp=NormalizeDouble(OrderClosePrice(),dig);
double osl=NormalizeDouble(OrderStopLoss(),dig);
double otp=NormalizeDouble(OrderTakeProfit(),dig);
if(ocp==osl){if(Sound)PlaySound("st.wav");index();return;}
if(ocp==otp){if(Sound)PlaySound("pr.wav");index();}
 return;}
//+==================================================================+
int index(){
   int a=Time[WindowBarsPerChart()],c=Time[0]*2;
 ObjectCreate("djfhrkoc",OBJ_RECTANGLE,0,a,WindowPriceMax(),c,WindowPriceMin());
      ObjectSet("djfhrkoc",OBJPROP_COLOR,Fon);          // - öâåò.
WindowRedraw();
ind=true;
  return(0);
  }
//+==================================================================+
void line(){if(OrderLevel!=true)return;
string name=OrderTicket();
ObjectDelete(name+"D");
color col=Red;
if(OrderType()==0){col=Blue;}
datetime a = OrderOpenTime();
double b = OrderOpenPrice();
int c = Time[0];
double d=Bid;
//+------------------------------------------------------------------+
ObjectCreate(name+"T",OBJ_ARROW,0,a,b);
       ObjectSet(name+"T",OBJPROP_COLOR,col);// - öâåò.
       ObjectSet(name+"T",OBJPROP_ARROWCODE,1);// - âïðàâî.
//+------------------------------------------------------------------+
ObjectCreate(name+"D",OBJ_TREND,0,a,b,c,d);
       ObjectSet(name+"D",OBJPROP_COLOR,col);          // - öâåò.
       ObjectSet(name+"D",OBJPROP_WIDTH,1);               // - øèðèíà.
       ObjectSet(name+"D",OBJPROP_STYLE,STYLE_DOT);       // 
       ObjectSet(name+"D",OBJPROP_RAY,0);                 // - îòðåçîê.
//+------------------------------------------------------------------+
return;}
//+==================================================================+
void deinit(){
for(int z=0;z<OrdersTotal();z++)
 {
 OrderSelect(z,SELECT_BY_POS);
 if(OrderSymbol()!=Symbol()||OrderType()>1)continue;
 string name=OrderTicket();
 ObjectDelete(name+"T");
 ObjectDelete(name+"D");
 }
 z=0;
 while(z<40)
 {
 ObjectDelete("open"+z);ObjectDelete("opens"+z);ObjectDelete("opensr"+z);
 ObjectDelete("historys"+z);ObjectDelete("historym"+z);
 ObjectDelete("history1"+z);ObjectDelete("history2"+z);
 z++;
 }
 z=OrdersHistoryTotal();
 while(z>0)
 {
 ObjectDelete("historys"+z);ObjectDelete("historym"+z);
 ObjectDelete("history1"+z);ObjectDelete("history2"+z);
 z--;
 }
ObjectDelete("historyr");ObjectDelete("historyrf");
return;}
//+==================================================================+
void del(){
for(int z=0;z<OrdersHistoryTotal();z++)
 {
 OrderSelect(z,SELECT_BY_POS,MODE_HISTORY);
 if(OrderSymbol()!=Symbol()||OrderType()>1)continue;
 string name=OrderTicket();
 ObjectDelete(name+"T");
 ObjectDelete(name+"D");
 }
return;}
//+==================================================================+
void history(){
//+-----------------------------------------------------------------+
if(ObjectFind("open0")==0)if(ObjectGet("open0",OBJPROP_XDISTANCE)!=ObjectGet("open0",OBJPROP_XDISTANCE)!=10){deinit();story();}
//+-----------------------------------------------------------------+
return;}
//+==================================================================+
void story(){his=true;
ObjectDelete("open0");
int y=5;
double sum=0;
double bal=AccountBalance();
int i=OrdersHistoryTotal();
for(;i>0;i--)
 {if(i<OrdersHistoryTotal()-45)break;
 OrderSelect(i-1,SELECT_BY_POS,MODE_HISTORY);
 if(OrderType()>1)continue;
 double pr=OrderProfit();
 sum+=pr;
 color c=Magenta;
 string z="-";
 if(pr>0){c=Gold;z="+";}
 if(pr==0){c=Green;z="";}
//+-----------------------------------------------------------------+
double AB=bal-(pr+OrderSwap()+OrderCommission());
double proc=pr/(AB/100);
double rt=MarketInfo(OrderSymbol(),MODE_POINT);
int pun=MathAbs((OrderOpenPrice()-OrderClosePrice())/rt);
//+-----------------------------------------------------------------+
 ObjectCreate("historys"+i,OBJ_LABEL,0,0,0);
ObjectSet("historys"+i, OBJPROP_CORNER, 1);
ObjectSet("historys"+i,OBJPROP_XDISTANCE,220);  
ObjectSet("historys"+i,OBJPROP_YDISTANCE,y);
ObjectSetText("historys"+i,OrderSymbol()+" : ",10,"Verdana",c);
//+-----------------------------------------------------------------+
 ObjectCreate("historym"+i,OBJ_LABEL,0,0,0);
ObjectSet("historym"+i, OBJPROP_CORNER, 1);
ObjectSet("historym"+i,OBJPROP_XDISTANCE,9);  
ObjectSet("historym"+i,OBJPROP_YDISTANCE,y);
ObjectSetText("historym"+i,z+DoubleToStr(MathAbs(pr),2)+"$",8,"Verdana",c);
//+-----------------------------------------------------------------+
ObjectCreate("history1"+i,OBJ_LABEL,0,0,0);
ObjectSet("history1"+i, OBJPROP_CORNER, 1);
ObjectSet("history1"+i,OBJPROP_XDISTANCE,80);  
ObjectSet("history1"+i,OBJPROP_YDISTANCE,y);
ObjectSetText("history1"+i,z+DoubleToStr(MathAbs(proc),2)+"% |",8,"Verdana",c);
//+-----------------------------------------------------------------+
ObjectCreate("history2"+i,OBJ_LABEL,0,0,0);
ObjectSet("history2"+i, OBJPROP_CORNER, 1);
ObjectSet("history2"+i,OBJPROP_XDISTANCE,160);  
ObjectSet("history2"+i,OBJPROP_YDISTANCE,y);
ObjectSetText("history2"+i,z+pun+" |",8,"Verdana",c);
//+-----------------------------------------------------------------+
y+=14;
 }
 //+-----------------------------------------------------------------+
  ObjectCreate("historyrf",OBJ_LABEL,0,0,0);
ObjectSet("historyrf", OBJPROP_CORNER, 1);
ObjectSet("historyrf",OBJPROP_XDISTANCE,9);  
ObjectSet("historyrf",OBJPROP_YDISTANCE,y);
ObjectSetText("historyrf","---------------------------------------",10,"Verdana",Teal);
//+-----------------------------------------------------------------+
  ObjectCreate("historyr",OBJ_LABEL,0,0,0);
ObjectSet("historyr", OBJPROP_CORNER, 1);
ObjectSet("historyr",OBJPROP_XDISTANCE,9);  
ObjectSet("historyr",OBJPROP_YDISTANCE,y+12);
ObjectSetText("historyr","ÁÀËÀÍÑ : "+DoubleToStr(AccountBalance(),2)+"$  |  "+"ÈÒÎÃÎ :   "+DoubleToStr(sum,2)+" $",9,"Verdana",Blue);
//+-----------------------------------------------------------------+
return;}
//+==================================================================+
void init(){
deinit();label();his=false;
return;}
//+==================================================================+