//+------------------------------------------------------------------+
//|                                                  #AbuawadNEW_v2.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
//---- input parameters
extern double       Sell_1_price; 
extern double       Sell_1_TP;
extern double       Sell_1_SL;
extern double       Sell_2_price;
extern double       Sell_2_TP;
extern double       Sell_2_SL;
extern double       Sell_3_price;
extern double       Sell_3_TP;
extern double       Sell_3_SL;
extern double       Buy_1_price;
extern double       Buy_1_TP;
extern double       Buy_1_SL;
extern double       Buy_2_price;
extern double       Buy_2_TP;
extern double       Buy_2_SL;
extern double       Buy_3_price;
extern double       Buy_3_TP;
extern double       Buy_3_SL;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----

  int handle;
  string s;
  double entry;
  double sl;
  double tp;
  int sell = 0;
  int buy = 0;
  
  handle=FileOpen("abuawad_data.txt",FILE_CSV|FILE_READ,',');
  
  if(handle<1)  {
     Print("File abuawad_data.txt not found, the last error is ", GetLastError());
     return(false);
  } else {
  
      while (FileIsEnding(handle)!= true) {
        s = FileReadString(handle);
        entry = FileReadNumber(handle);
        tp = FileReadNumber(handle);
        sl = FileReadNumber(handle);
        
        if ( s == "s") {
            // sell
            sell++;
            switch (sell) {
               case 1:
                  Sell_1_price = entry;
                  Sell_1_TP = tp;
                  Sell_1_SL = sl;
                  break;
                  
               case 2:
                  Sell_2_price = entry;
                  Sell_2_TP = tp;
                  Sell_2_SL = sl;
                  break;

               case 3:
                  Sell_3_price = entry;
                  Sell_3_TP = tp;
                  Sell_3_SL = sl;
                  break;
               
            }
        
         }
                 
        if (s == "b") {
            // buy
            buy++;
            switch (buy) {
               case 1:
                  Buy_1_price = entry;
                  Buy_1_TP = tp;
                  Buy_1_SL = sl;
                  break;
                  
               case 2:
                  Buy_2_price = entry;
                  Buy_2_TP = tp;
                  Buy_2_SL = sl;
                  break;

               case 3:
                  Buy_3_price = entry;
                  Buy_3_TP = tp;
                  Buy_3_SL = sl;
                  break;
               
            }


        }

  
   }
   FileClose(handle);
   

   }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
   ObjectDelete("Sell_1_price_line");
   ObjectDelete("Sell_1_price_label");

   ObjectDelete("Sell_1_TP_line");
   ObjectDelete("Sell_1_TP_label");

   ObjectDelete("Sell_1_SL_line");
   ObjectDelete("Sell_1_SL_label");

// --

   ObjectDelete("Sell_2_price_line");
   ObjectDelete("Sell_2_price_label");

   ObjectDelete("Sell_2_TP_line");
   ObjectDelete("Sell_2_TP_label");

   ObjectDelete("Sell_2_SL_line");
   ObjectDelete("Sell_2_SL_label");

// --

   ObjectDelete("Sell_3_price_line");
   ObjectDelete("Sell_3_price_label");

   ObjectDelete("Sell_3_TP_line");
   ObjectDelete("Sell_3_TP_label");

   ObjectDelete("Sell_3_SL_line");
   ObjectDelete("Sell_3_SL_label");

   
//----

   ObjectDelete("Buy_1_price_line");
   ObjectDelete("Buy_1_price_label");

   ObjectDelete("Buy_1_TP_line");
   ObjectDelete("Buy_1_TP_label");

   ObjectDelete("Buy_1_SL_line");
   ObjectDelete("Buy_1_SL_label");

// --

   ObjectDelete("Buy_2_price_line");
   ObjectDelete("Buy_2_price_label");

   ObjectDelete("Buy_2_TP_line");
   ObjectDelete("Buy_2_TP_label");

   ObjectDelete("Buy_2_SL_line");
   ObjectDelete("Buy_2_SL_label");

// --

   ObjectDelete("Buy_3_price_line");
   ObjectDelete("Buy_3_price_label");

   ObjectDelete("Buy_3_TP_line");
   ObjectDelete("Buy_3_TP_label");

   ObjectDelete("Buy_3_SL_line");
   ObjectDelete("Buy_3_SL_label");

   
//----



   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
   if (Sell_1_price > 0) 
   {
      ObjectCreate("Sell_1_price_line", OBJ_HLINE,0, Time[0],Sell_1_price);
      ObjectSet("Sell_1_price_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_1_price_line", OBJPROP_STYLE, STYLE_DASH);
      if(ObjectFind("Sell_1_price_label") != 0)
      {
         ObjectCreate("Sell_1_price_label", OBJ_TEXT, 0, Time[0], Sell_1_price);
         ObjectSetText("Sell_1_price_label", "                                  Sell 1", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_1_price_label", 0, Time[0], Sell_1_price);
      }
   }

   if (Sell_1_TP > 0) 
   {
      ObjectCreate("Sell_1_TP_line", OBJ_HLINE,0, Time[0],Sell_1_TP);
      ObjectSet("Sell_1_TP_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_1_TP_line", OBJPROP_STYLE, STYLE_DOT );
      if(ObjectFind("Sell_1_TP_label") != 0)
      {
         ObjectCreate("Sell_1_TP_label", OBJ_TEXT, 0, Time[0], Sell_1_TP);
         ObjectSetText("Sell_1_TP_label", "                                  Sell 1 T/P", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_1_TP_label", 0, Time[0], Sell_1_TP);
      }
   }

   if (Sell_1_SL > 0) 
   {
      ObjectCreate("Sell_1_SL_line", OBJ_HLINE,0, Time[0],Sell_1_SL);
      ObjectSet("Sell_1_SL_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_1_SL_line", OBJPROP_STYLE, STYLE_DASHDOTDOT );
      if(ObjectFind("Sell_1_SL_label") != 0)
      {
         ObjectCreate("Sell_1_SL_label", OBJ_TEXT, 0, Time[0], Sell_1_SL);
         ObjectSetText("Sell_1_SL_label", "                                  Sell 1 S/L", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_1_SL_label", 0, Time[0], Sell_1_SL);
      }
   }

   if (Sell_2_price > 0 ) 
   {
      ObjectCreate("Sell_2_price_line", OBJ_HLINE,0, Time[0],Sell_2_price);
      ObjectSet("Sell_2_price_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_2_price_line", OBJPROP_STYLE, STYLE_DASH);
      if(ObjectFind("Sell_2_price_label") != 0)
      {
         ObjectCreate("Sell_2_price_label", OBJ_TEXT, 0, Time[0], Sell_2_price);
         ObjectSetText("Sell_2_price_label", "                                  Sell 2", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_2_price_label", 0, Time[0], Sell_2_price);
      }
   }


   if (Sell_2_TP > 0) 
   {
      ObjectCreate("Sell_2_TP_line", OBJ_HLINE,0, Time[0],Sell_2_TP);
      ObjectSet("Sell_2_TP_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_2_TP_line", OBJPROP_STYLE, STYLE_DOT );
      if(ObjectFind("Sell_2_TP_label") != 0)
      {
         ObjectCreate("Sell_2_TP_label", OBJ_TEXT, 0, Time[0], Sell_2_TP);
         ObjectSetText("Sell_2_TP_label", "                                  Sell 2 T/P", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_2_TP_label", 0, Time[0], Sell_2_TP);
      }
   }

   if (Sell_2_SL > 0) 
   {
      ObjectCreate("Sell_2_SL_line", OBJ_HLINE,0, Time[0],Sell_2_SL);
      ObjectSet("Sell_2_SL_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_2_SL_line", OBJPROP_STYLE, STYLE_DASHDOTDOT );
      if(ObjectFind("Sell_2_SL_label") != 0)
      {
         ObjectCreate("Sell_2_SL_label", OBJ_TEXT, 0, Time[0], Sell_2_SL);
         ObjectSetText("Sell_2_SL_label", "                                  Sell 2 S/L", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_2_SL_label", 0, Time[0], Sell_2_SL);
      }
   }


   if ( Sell_3_price > 0) 
   {
      ObjectCreate("Sell_3_price_line", OBJ_HLINE,0, Time[0],Sell_3_price);
      ObjectSet("Sell_3_price_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_3_price_line", OBJPROP_STYLE, STYLE_DASH);
      if(ObjectFind("Sell_3_price_label") != 0)
      {
         ObjectCreate("Sell_3_price_label", OBJ_TEXT, 0, Time[0], Sell_3_price);
         ObjectSetText("Sell_3_price_label", "                                  Sell 3", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_3_price_label", 0, Time[0], Sell_3_price);
      }
   }
   
   if (Sell_3_TP > 0) 
   {
      ObjectCreate("Sell_3_TP_line", OBJ_HLINE,0, Time[0],Sell_3_TP);
      ObjectSet("Sell_3_TP_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_3_TP_line", OBJPROP_STYLE, STYLE_DOT );
      if(ObjectFind("Sell_3_TP_label") != 0)
      {
         ObjectCreate("Sell_3_TP_label", OBJ_TEXT, 0, Time[0], Sell_3_TP);
         ObjectSetText("Sell_3_TP_label", "                                  Sell 3 T/P", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_3_TP_label", 0, Time[0], Sell_3_TP);
      }
   }

   if (Sell_3_SL > 0) 
   {
      ObjectCreate("Sell_3_SL_line", OBJ_HLINE,0, Time[0],Sell_3_SL);
      ObjectSet("Sell_3_SL_line", OBJPROP_COLOR, Crimson);
      ObjectSet("Sell_3_SL_line", OBJPROP_STYLE, STYLE_DASHDOTDOT );
      if(ObjectFind("Sell_3_SL_label") != 0)
      {
         ObjectCreate("Sell_3_SL_label", OBJ_TEXT, 0, Time[0], Sell_3_SL);
         ObjectSetText("Sell_3_SL_label", "                                  Sell 3 S/L", 10, "Arial", Crimson);
      }
      else
      {
         ObjectMove("Sell_3_SL_label", 0, Time[0], Sell_3_SL);
      }
   }
   
//----



   if (Buy_1_price > 0) 
   {
      ObjectCreate("Buy_1_price_line", OBJ_HLINE,0, Time[0],Buy_1_price);
      ObjectSet("Buy_1_price_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_1_price_line", OBJPROP_STYLE, STYLE_DASH);
      if(ObjectFind("Buy_1_price_label") != 0)
      {
         ObjectCreate("Buy_1_price_label", OBJ_TEXT, 0, Time[0], Buy_1_price);
         ObjectSetText("Buy_1_price_label", "                                  Buy 1", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_1_price_label", 0, Time[0], Buy_1_price);
      }
   }

   if (Buy_1_TP > 0) 
   {
      ObjectCreate("Buy_1_TP_line", OBJ_HLINE,0, Time[0],Buy_1_TP);
      ObjectSet("Buy_1_TP_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_1_TP_line", OBJPROP_STYLE, STYLE_DOT );
      if(ObjectFind("Buy_1_TP_label") != 0)
      {
         ObjectCreate("Buy_1_TP_label", OBJ_TEXT, 0, Time[0], Buy_1_TP);
         ObjectSetText("Buy_1_TP_label", "                                  Buy 1 T/P", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_1_TP_label", 0, Time[0], Buy_1_TP);
      }
   }

   if (Buy_1_SL > 0) 
   {
      ObjectCreate("Buy_1_SL_line", OBJ_HLINE,0, Time[0],Buy_1_SL);
      ObjectSet("Buy_1_SL_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_1_SL_line", OBJPROP_STYLE, STYLE_DASHDOTDOT );
      if(ObjectFind("Buy_1_SL_label") != 0)
      {
         ObjectCreate("Buy_1_SL_label", OBJ_TEXT, 0, Time[0], Buy_1_SL);
         ObjectSetText("Buy_1_SL_label", "                                  Buy 1 S/L", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_1_SL_label", 0, Time[0], Buy_1_SL);
      }
   }

   if (Buy_2_price > 0 ) 
   {
      ObjectCreate("Buy_2_price_line", OBJ_HLINE,0, Time[0],Buy_2_price);
      ObjectSet("Buy_2_price_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_2_price_line", OBJPROP_STYLE, STYLE_DASH);
      if(ObjectFind("Buy_2_price_label") != 0)
      {
         ObjectCreate("Buy_2_price_label", OBJ_TEXT, 0, Time[0], Buy_2_price);
         ObjectSetText("Buy_2_price_label", "                                  Buy 2", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_2_price_label", 0, Time[0], Buy_2_price);
      }
   }


   if (Buy_2_TP > 0) 
   {
      ObjectCreate("Buy_2_TP_line", OBJ_HLINE,0, Time[0],Buy_2_TP);
      ObjectSet("Buy_2_TP_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_2_TP_line", OBJPROP_STYLE, STYLE_DOT );
      if(ObjectFind("Buy_2_TP_label") != 0)
      {
         ObjectCreate("Buy_2_TP_label", OBJ_TEXT, 0, Time[0], Buy_2_TP);
         ObjectSetText("Buy_2_TP_label", "                                  Buy 2 T/P", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_2_TP_label", 0, Time[0], Buy_2_TP);
      }
   }

   if (Buy_2_SL > 0) 
   {
      ObjectCreate("Buy_2_SL_line", OBJ_HLINE,0, Time[0],Buy_2_SL);
      ObjectSet("Buy_2_SL_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_2_SL_line", OBJPROP_STYLE, STYLE_DASHDOTDOT );
      if(ObjectFind("Buy_2_SL_label") != 0)
      {
         ObjectCreate("Buy_2_SL_label", OBJ_TEXT, 0, Time[0], Buy_2_SL);
         ObjectSetText("Buy_2_SL_label", "                                  Buy 2 S/L", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_2_SL_label", 0, Time[0], Buy_2_SL);
      }
   }


   if ( Buy_3_price > 0) 
   {
      ObjectCreate("Buy_3_price_line", OBJ_HLINE,0, Time[0],Buy_3_price);
      ObjectSet("Buy_3_price_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_3_price_line", OBJPROP_STYLE, STYLE_DASH);
      if(ObjectFind("Buy_3_price_label") != 0)
      {
         ObjectCreate("Buy_3_price_label", OBJ_TEXT, 0, Time[0], Buy_3_price);
         ObjectSetText("Buy_3_price_label", "                                  Buy 3", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_3_price_label", 0, Time[0], Buy_3_price);
      }
   }
   
   if (Buy_3_TP > 0) 
   {
      ObjectCreate("Buy_3_TP_line", OBJ_HLINE,0, Time[0],Buy_3_TP);
      ObjectSet("Buy_3_TP_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_3_TP_line", OBJPROP_STYLE, STYLE_DOT );
      if(ObjectFind("Buy_3_TP_label") != 0)
      {
         ObjectCreate("Buy_3_TP_label", OBJ_TEXT, 0, Time[0], Buy_3_TP);
         ObjectSetText("Buy_3_TP_label", "                                  Buy 3 T/P", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_3_TP_label", 0, Time[0], Buy_3_TP);
      }
   }

   if (Buy_3_SL > 0) 
   {
      ObjectCreate("Buy_3_SL_line", OBJ_HLINE,0, Time[0],Buy_3_SL);
      ObjectSet("Buy_3_SL_line", OBJPROP_COLOR, Green);
      ObjectSet("Buy_3_SL_line", OBJPROP_STYLE, STYLE_DASHDOTDOT );
      if(ObjectFind("Buy_3_SL_label") != 0)
      {
         ObjectCreate("Buy_3_SL_label", OBJ_TEXT, 0, Time[0], Buy_3_SL);
         ObjectSetText("Buy_3_SL_label", "                                  Buy 3 S/L", 10, "Arial", Green);
      }
      else
      {
         ObjectMove("Buy_3_SL_label", 0, Time[0], Buy_3_SL);
      }
   }

   
//----
   return(0);
  }
//+------------------------------------------------------------------+