Orders Execution
Checks for the total of open ordersChecks for the total of closed orders
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
Informer
#property indicator_chart_window
//+------------------------------------------------------------------+
extern int Lap=1140;
extern bool Sound=true;
extern bool OrderLevel=true;
extern color prib=Gold;
extern color ubyt=Magenta;
extern color zero=MediumSeaGreen;
extern color otloj=Turquoise;
extern color razdel=Coral;
extern color Fon=Yellow;
//+------------------------------------------------------------------+
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;
int tot=OrdersTotal();
if(tot>0){f=true;}
if(ind==true){ObjectDelete("djfhrkoc");ind=false;}
if(f==false)return;
if(tot==0&&f==true)
{
open();
label();
f=false;
if(ord>tot)sound();
if(ord!=tot)del();
ord=tot;
return;
}
open();
if(ord>tot)sound();
if(ord!=tot)del();
ord=tot;
or=OrdersTotal();
return;}
//+****************************************************************************+
//+==================================================================+
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);}
 }
//+------------------------------------------------------------------+
double dengirisk=pipss*OrderLots()*tickvalue;
string denrisk=DoubleToStr(dengirisk,2);
//+------------------------------------------------------------------+
if(type>1){cvet=otloj;}else if(OrderSymbol()==Symbol())line();
string TEXT=urst+"  | "+rick+" % | "+denrisk+" $  ";
string substr = StringSubstr(urst,0,1);
if(substr==" ")TEXT=urst+"  | -"+rick+" % | -"+denrisk+" $  ";else TEXT=urst+"  | +"+rick+" % | +"+denrisk+" $  ";
 if(stop==0)TEXT="  NO  | ???  % | ??? $  ";
 if(stop==price)TEXT=" Á/Ó | 0 % | 0 $  ";
ObjectCreate("open"+z,OBJ_LABEL,0,0,0);
ObjectSet("open"+z, OBJPROP_CORNER, 0);
ObjectSet("open"+z,OBJPROP_XDISTANCE,Lap);  
ObjectSet("open"+z,OBJPROP_YDISTANCE,vertikal);
ObjectSetText("open"+z,OrderSymbol()+" : Risk ("+TEXT+")",7,"Verdana",cvet);
//+------------------------------------------------------------------+
double ask=MarketInfo(OrderSymbol(),MODE_ASK);
double bid=MarketInfo(OrderSymbol(),MODE_BID);
if(type<1){int punk=(bid-price)/pips;string punkty=DoubleToStr(punk,0);}
else {punk=(price-ask)/pips;punkty=DoubleToStr(punk,0);}
if(Profit>0)string k="+"; else k="";
switch(type)
{
case 0: TEXT="BUY :    Profit ( "+k+punkty+" | "+k+DoubleToStr(proc,2)+" % | "+k+DoubleToStr(Profit,2)+" $  )";break;
case 1: TEXT="SELL :    Profit ( "+k+punkty+" | "+k+DoubleToStr(proc,2)+" % | "+k+DoubleToStr(Profit,2)+" $  )";break;
case 2: TEXT="BUY LIMIT";break;
case 3: TEXT="SELL LIMIT";break;
case 4: TEXT="BUY STOP";break;
case 5: TEXT="SELL STOP";
}
//+------------------------------------------------------------------+
ObjectCreate("opens"+z,OBJ_LABEL,0,0,0);
ObjectSet("opens"+z, OBJPROP_CORNER, 0);
ObjectSet("opens"+z,OBJPROP_XDISTANCE,Lap);  
ObjectSet("opens"+z,OBJPROP_YDISTANCE,vertikal+11);
ObjectSetText("opens"+z,TEXT,7,"Verdana",cvet);
//+------------------------------------------------------------------+*/
ObjectCreate("opensr"+z,OBJ_LABEL,0,0,0);
ObjectSet("opensr"+z, OBJPROP_CORNER, 0);
ObjectSet("opensr"+z,OBJPROP_XDISTANCE,Lap);  
ObjectSet("opensr"+z,OBJPROP_YDISTANCE,vertikal+20);
ObjectSetText("opensr"+z,"-------------------------------------------------",7,"Verdana",razdel);
//+------------------------------------------------------------------+*/
vertikal+=28;
}//+------------------------------------------------------------------+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;
case 5: tf="5 ìèíóò";break;
case 15: tf="15 ìèíóò";break;
case 30: tf="30 ìèíóò";break;
case 60: tf="1 ÷àñ";break;
case 240: tf="4 ÷àñà";break;
case 1440: tf="1 äåíü";break;
case 10080: tf="1 íåäåëÿ";break;
case 43200: tf="1 ìåñÿö";break;
}
ObjectCreate("open0",OBJ_LABEL,0,0,0);
ObjectSet("open0", OBJPROP_CORNER, 1);
ObjectSet("open0",OBJPROP_XDISTANCE,10);  
ObjectSet("open0",OBJPROP_YDISTANCE,3);
ObjectSetText("open0",Symbol()+" * "+tf,15,"Times New Roman",cvt);
//+-------------------------------------------------------------------+
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;}
//+==================================================================+
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)!=Lap&&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;}
//+==================================================================+

Comments