
#property indicator_separate_window

#property indicator_buffers 8
#property indicator_color1 Black
#property indicator_color2 Black
#property indicator_color3 Black
#property indicator_color4 Black
#property indicator_color5 Blue
#property indicator_color6 Yellow
#property indicator_color7 LimeGreen
#property indicator_color8 FireBrick





extern string paire  = "EURGBP";
extern int Time_frime= 0;

extern bool      Show_SAR =1;
extern double    Step=0.02;
extern double    Maximum=0.2;

extern bool      Show_BB  =1;
extern int       BandsPeriod=20;
extern double    BandsDeviations=2.0;

extern bool      Show_MA_1  =1;
extern int       PRD_1=50;

extern bool      Show_MA_2  =1;
extern int       PRD_2=100;

extern bool      Show_MA_3  =1;
extern int       PRD_3=150;

extern bool      Show_MA_4  =1;
extern int       PRD_4=150;

extern string setup ="Définition du style de prix et MA";
extern string price ="CLOSE";
extern string ma_style ="SMA";

extern color     Up= Green;
extern color     Down = Red;
extern int Corps= 3;
extern int Meches=1;
extern color     ligne_prix= Black;

double ind_1[];
double ind_2[];
double ind_3[];
double ind_4[];
double ind_5[];
double ind_6[];
double ind_7[];
double ind_8[];


int init() {
   IndicatorShortName(paire);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, ind_1);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, ind_2);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, ind_3);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,159);
   SetIndexBuffer(3,ind_4);
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, ind_5);
   SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(5, ind_6);
   SetIndexStyle(6, DRAW_LINE);
   SetIndexBuffer(6, ind_7);
   SetIndexStyle(7, DRAW_LINE);
   SetIndexBuffer(7, ind_8);
   
   

   return (0);
}

int deinit() {
   Comment("");
   return (0);
}

int start() {
   
   string l_name_44;
   string l_name_52;
 
   string ls_0 = paire;
   int li_8 = WindowFind(ls_0);
   double prix,mode;

   for (int i = 0; i < Bars; i++) {
   for (int k = i; k < 10 + i; k++) 
   for (k = i; k < 10 + i; k++) 
      
       {
                                                                // Définition du prix
     if (price == "CLOSE")                  prix= PRICE_CLOSE;
     if (price == "TYPICAL")                prix= PRICE_TYPICAL;
     if (price == "HIGH")                   prix= PRICE_HIGH;
     if (price == "LOW")                    prix= PRICE_LOW;
     if (price == "OPEN")                   prix= PRICE_OPEN;
     if (price == "MEDIAN")                 prix= PRICE_MEDIAN;
     if (price == "WEIGHTED")               prix= PRICE_WEIGHTED;
                                                                 // Définition du style moving average
 
     if (ma_style == "SMA")                 mode= MODE_SMA;
     if (ma_style == "EMA")                 mode= MODE_EMA;
     if (ma_style == "LWMA")                mode= MODE_LWMA;
     if (ma_style == "SMOOT")               mode= MODE_SMMA;

       if (Show_BB == 1)    ind_1[i]= iMA(paire,Time_frime,BandsPeriod,0,MODE_SMA,PRICE_CLOSE,i);
       if (Show_BB == 1)    ind_2[i]= iBands(paire,Time_frime,BandsPeriod,BandsDeviations,0,PRICE_CLOSE,MODE_LOWER,i);
       if (Show_BB == 1)    ind_3[i]= iBands(paire,Time_frime,BandsPeriod,BandsDeviations,0,PRICE_CLOSE,MODE_UPPER,i);
       if (Show_SAR == 1)   ind_4[i]= iSAR(paire,Time_frime,Step,Maximum,i);
       if (Show_MA_1 == 1)  ind_5[i]= iMA(paire,Time_frime,PRD_1,0,mode,prix,i);
       if (Show_MA_2 == 1)  ind_6[i]= iMA(paire,Time_frime,PRD_2,0,mode,prix,i);
       if (Show_MA_3 == 1)  ind_7[i]= iMA(paire,Time_frime,PRD_3,0,mode,prix,i);
       if (Show_MA_4 == 1)  ind_8[i]= iMA(paire,Time_frime,PRD_4,0,mode,prix,i);



        
        
        
        }
   }
   Sleep(1000);
   ObjectsDeleteAll(li_8);
   for (k = 0; k <= Bars; k++) {
      l_name_44 = "TimingHL" + k;
      ObjectCreate(l_name_44, OBJ_TREND, li_8, Time[k], iHigh(paire,Time_frime,k), Time[k], iLow(paire,Time_frime,k));
      ObjectSet(l_name_44, OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet(l_name_44, OBJPROP_RAY, FALSE);
      ObjectSet(l_name_44, OBJPROP_WIDTH, Meches);
      l_name_52 = "TimingOC" + k;
      ObjectCreate(l_name_52, OBJ_TREND, li_8, Time[k], iOpen(paire,Time_frime,k), Time[k], iClose(paire,Time_frime,k));
      ObjectSet(l_name_52, OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet(l_name_52, OBJPROP_RAY, FALSE);
      ObjectSet(l_name_52, OBJPROP_WIDTH, Corps);
      if (iOpen(paire,0,k) <= iClose(paire,0,k)) {
      ObjectSet(l_name_44, OBJPROP_COLOR, Up);
      ObjectSet(l_name_52, OBJPROP_COLOR, Up);
      } else {
      ObjectSet(l_name_44, OBJPROP_COLOR, Down);
      ObjectSet(l_name_52, OBJPROP_COLOR, Down);
      }
   }
     ObjectCreate("actuel_price", OBJ_HLINE, li_8, 0, iClose(paire,0,0));
     ObjectSet("actuel_price", OBJPROP_COLOR, ligne_prix);
   return (0);
}