//+------------------------------------------------------------------+
//|             Copyright © 2010, Konstantin http://www.fxaktiv.com  |
//|                        panelektrik@yandex.ru skype pan--elektrik |
//|                                ISQ 561090193 Ìîá.+380 50 7115118 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Konstantin http://www.fxaktiv.com  panelektrik@yandex.ru"
#property link      "http://www.fxaktiv.com  panelektrik@yandex.ru  skype pan--elektrik ISQ 561090193"

#property show_inputs

extern int maxCLOSE=+100;
extern int minCLOSE=-100;

//+------------------------------------------------------------------+
int objekt1(string Trade)
   {
    ObjectCreate("max",OBJ_LABEL,0,0,0);
    ObjectSetText("max","max  =  +"+Trade, 10,"Times New Roman",DodgerBlue);
    ObjectSet("max", OBJPROP_CORNER, 1);
    ObjectSet("max", OBJPROP_XDISTANCE, 20);
    ObjectSet("max", OBJPROP_YDISTANCE, 10);
   }
int objekt2(string Trade)
   {
    ObjectCreate("min",OBJ_LABEL,0,0,0);
    ObjectSetText("min","min  =   "+Trade, 10,"Times New Roman",Tomato);
    ObjectSet("min", OBJPROP_CORNER, 1);
    ObjectSet("min", OBJPROP_XDISTANCE, 20);
    ObjectSet("min", OBJPROP_YDISTANCE, 30);
   }  
//+------------------------------------------------------------------+
int orders(){int j=0;for(int i=0;i<OrdersTotal();i++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
 if(OrderSymbol()==Symbol())j++;}return(j);}
//+------------------------------------------------------------------+
 double Profit(){double j;RefreshRates();for(int i=OrdersTotal(); i+1>=0; i--){
 if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)&&(Symbol()==OrderSymbol()))j=j+OrderProfit();}return(j);}
//+------------------------------------------------------------------+
 int ALLCloseBUY(){RefreshRates();for(int i=OrdersTotal(); i+1>=0; i--){
 if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)&&(OrderType()==OP_BUY)&&(Symbol()==OrderSymbol()))
 {OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(OrderSymbol(),MODE_DIGITS)),MarketInfo(OrderSymbol(),MODE_SPREAD));}}}
//+------------------------------------------------------------------+
 int ALLCloseSELL(){RefreshRates();for(int i=OrdersTotal(); i+1>=0; i--){
 if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)&&(OrderType()==OP_SELL)&&(Symbol()==OrderSymbol()))
 {OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(OrderSymbol(),MODE_DIGITS)),MarketInfo(OrderSymbol(),MODE_SPREAD));}}}
//+------------------------------------------------------------------+
int start()
{
 while(!IsStopped())
 {
 if(Profit()>maxCLOSE||Profit()<minCLOSE){ALLCloseBUY();ALLCloseSELL();}
 if(orders()==0){PlaySound("Wait.wav");break;}
 Sleep(1000);
 Comment(Profit());
 objekt1(maxCLOSE);
 objekt2(minCLOSE);
 }
}
int deinit(){ObjectDelete("max");ObjectDelete("min");} 
//+------------------------------------------------------------------+