//+------------------------------------------------------------------+
//|                                                          %BB.mq4 |
//|                                    Copyright ? 2008, Walter Choy |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright sohocool"
#property link      "www.sohocool"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Aqua
#property indicator_color3 Blue
#property indicator_color4 Violet
#property indicator_color5 Lime
#property indicator_color6 Orange
#property indicator_color7 Crimson
#property indicator_color8 Red



extern int    KIJUN_period = 26;
extern int    NbOfBars=600;
extern int    tframe1 =1;
extern bool tf1=true;
extern int    tframe2 =5;
extern bool tf2=true;
extern int    tframe3 =15;
extern bool tf3=true;
extern int    tframe4 =60;
extern bool tf4=true;
extern int    tframe5 =240;
extern bool tf5=true;
extern int    tframe6 =1440;
extern bool tf6=true;
extern int    tframe7 =30;
extern bool tf7=true;
extern int    tTenkan =1;
extern bool tTK=true;



//---- buffers
double KIJUN1[];
double KIJUN2[];
double KIJUN3[];
double KIJUN4[];
double KIJUN5[];
double KIJUN6[];
double KIJUN7[];
double Tenkan[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,EMPTY,2,Yellow);
   SetIndexBuffer(0, KIJUN1);
   SetIndexLabel(0, "KIJUN_1m");
   SetIndexDrawBegin(0, KIJUN_period);
   
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, KIJUN2);
   SetIndexLabel(1, "KIJUN_5m");
   SetIndexDrawBegin(1, KIJUN_period);
   
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, KIJUN3);
   SetIndexLabel(2, "KIJUN_15m");
   SetIndexDrawBegin(2, KIJUN_period);
   
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, KIJUN4);
   SetIndexLabel(3, "KIJUN_1H");
   SetIndexDrawBegin(3, KIJUN_period);
   
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, KIJUN5);
   SetIndexLabel(4, "KIJUN_4H");
   SetIndexDrawBegin(4, KIJUN_period);
   
   SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(5, KIJUN6);
   SetIndexLabel(5, "KIJUN_daily");
   SetIndexDrawBegin(5, KIJUN_period);
   
   SetIndexStyle(6, DRAW_LINE);
   SetIndexBuffer(6, KIJUN7);
   SetIndexLabel(6, "KIJUN_30m");
   SetIndexDrawBegin(6, KIJUN_period);
   
   SetIndexStyle(7, DRAW_LINE,EMPTY,2,Red);
   SetIndexBuffer(7, Tenkan);
   SetIndexLabel(7, "TENKAN 1m");
   SetIndexDrawBegin(7, KIJUN_period);
   
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    for(int i=0; i<NbOfBars; i++)
   {
       if (tf1)
       KIJUN1[i] = iIchimoku(NULL,0,9,tframe1*KIJUN_period,52, MODE_KIJUNSEN, i);
       if (tf2)  
       KIJUN2[i] = iIchimoku(NULL,0,9,tframe2*KIJUN_period,52, MODE_KIJUNSEN, i);
       if (tf3)
       KIJUN3[i] = iIchimoku(NULL,0,9,tframe3*KIJUN_period,52, MODE_KIJUNSEN, i);
       if (tf4)
       KIJUN4[i] = iIchimoku(NULL,0,9,tframe4*KIJUN_period,52, MODE_KIJUNSEN, i);  //60min
       if (tf5)
       KIJUN5[i] = iIchimoku(NULL,0,9,tframe5*KIJUN_period,52, MODE_KIJUNSEN, i);  //4H
       if (tf6)
       KIJUN6[i] = iIchimoku(NULL,0,9,tframe6*KIJUN_period,52, MODE_KIJUNSEN, i);  // Day
       if (tf7)
       KIJUN7[i] = iIchimoku(NULL,0,9,tframe7*KIJUN_period,52, MODE_KIJUNSEN, i);  // 30min
       if (tTK)
       Tenkan[i] = iIchimoku(NULL,0,9,tframe1*KIJUN_period,52, MODE_TENKANSEN, i);  //  Tenkansen
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+