//+------------------------------------------------------------------+
//|                                                 Ichi_OsMA_TC.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_separate_window

#property indicator_buffers 2

#property indicator_color1 Green
#property indicator_color2 Red

extern int Tenkan=9;
extern int Kijun=26;
extern int Senkou=52;




double ExtMapBuffer2[];
double ExtMapBuffer3[];

//+------

int init()
  {


  

  SetIndexBuffer    (0,ExtMapBuffer2);
  SetIndexStyle     (0,DRAW_HISTOGRAM);
  SetIndexDrawBegin (0,Senkou);
 
  SetIndexBuffer    (1,ExtMapBuffer3);
  SetIndexStyle     (1,DRAW_HISTOGRAM);
  SetIndexDrawBegin (1,Senkou);



   SetIndexLabel(0,"Tenkan");
   SetIndexLabel(1,"PriceChk");



IndicatorShortName("Ichi OsMA TC ("+Tenkan+","+Kijun+","+Senkou+") ");

   return(0);
  }

//+----------

int start()
  {
   int i,limit,counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   
   limit=Bars-counted_bars;
   
   
   for (i=limit; i>=0; i--)
     {

      
  double d1  = iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_TENKANSEN,   i)-
                      iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_SENKOUSPANB, i-Kijun);

  double d2  = iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_CHINKOUSPAN, i+Kijun)-
                      iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_SENKOUSPANB, i-Kijun);
   
  if(d2>=d1)
  {
    ExtMapBuffer2[i] = d2-d1;
    ExtMapBuffer3[i] = EMPTY_VALUE;
  }
  else
  {
    ExtMapBuffer3[i] = d2-d1;
    ExtMapBuffer2[i] = EMPTY_VALUE  ;
  }
  
  }
   
   
    
  return(0);
 }
//+-----------