//Hikkake Pattern Indicator
#property copyright "Copyright © 2007, modulatum."
#property indicator_chart_window
int buy = 0, sell = 0, i = 0;
extern int minutes;
int init()
  {

   return(0);
  }
  
  int deinit(){
  ObjectsDeleteAll(0,0);
  return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  double bar0H = iHigh(NULL,minutes,2);
  double bar1H = iHigh(NULL,minutes,1);
  double bar2H = iHigh(NULL,minutes,0);
  double bar0L = iLow(NULL,minutes,2);
  double bar1L = iLow(NULL,minutes,1);
  double bar2L = iLow(NULL,minutes,0);
  double bar0C = iClose(NULL,minutes,2);
  double bar1C = iClose(NULL,minutes,1);
  double bar2C = iClose(NULL,minutes,0);
  double bar1R = MathAbs(bar1H - bar1L);
  double bar0R = MathAbs(bar0H - bar0L);
  
  if(bar1L >= bar0L && bar1H <= bar0H){
   if(bar2H > bar1H && bar2L > bar1L && sell == 0){
      sell = 1;
      buy = 0;
      i = i + 1;
      ObjectCreate("H Sell " + minutes + " " +i,0,0,TimeCurrent(),Close[0]);
      ObjectSet("H Sell" + minutes + " " +i,OBJPROP_COLOR,Red);
      ObjectSet("H Sell" + minutes + " " +i,OBJPROP_WIDTH,1); 
      ObjectSet("H Sell" + minutes + " " +i,OBJPROP_STYLE,STYLE_SOLID);
      Alert("Sell " + Symbol() + " ("+minutes+") (Hikkake)");
		//bear;
	}
	if(bar2H < bar1H && bar2L < bar1L && buy == 0){
	sell = 0;
      buy = 1;
      i = i + 1;
            ObjectCreate("H Buy" + minutes + " " +i,0,0,TimeCurrent(),Close[0]);
      ObjectSet("H Buy" + minutes + " " +i,OBJPROP_COLOR,YellowGreen);
      ObjectSet("H Buy" + minutes + " " +i,OBJPROP_WIDTH,1); 
      ObjectSet("H Buy" + minutes + " " +i,OBJPROP_STYLE,STYLE_SOLID);
      Alert("Buy " + Symbol() + " ("+minutes+") (Hikkake)");
		//bull;
	}
	
	
		if(bar2H < bar1H && bar2L < bar1L && buy == 0 && bar1C == bar1L && bar1R < bar0R){
	sell = 0;
      buy = 1;
      i = i + 1;
            ObjectCreate("H Buy" + minutes + " " +i,0,0,TimeCurrent(),Close[0]);
      ObjectSet("H Buy" + minutes + " " +i,OBJPROP_COLOR,YellowGreen);
      ObjectSet("H Buy" + minutes + " " +i,OBJPROP_WIDTH,1); 
      ObjectSet("H Buy" + minutes + " " +i,OBJPROP_STYLE,STYLE_SOLID);
      Alert("Reversal Buy " + Symbol() + " ("+minutes+") (Hikkake)");
		//bull;
	}
	if(bar2H > bar1H && bar2L > bar1L && sell == 0 && bar1C == bar1H && bar1R < bar0R){
      sell = 1;
      buy = 0;
      i = i + 1;
      ObjectCreate("H Sell " + minutes + " " +i,0,0,TimeCurrent(),Close[0]);
      ObjectSet("H Sell" + minutes + " " +i,OBJPROP_COLOR,Red);
      ObjectSet("H Sell" + minutes + " " +i,OBJPROP_WIDTH,1); 
      ObjectSet("H Sell" + minutes + " " +i,OBJPROP_STYLE,STYLE_SOLID);
      Alert("Reversal Sell " + Symbol() + " ("+minutes+") (Hikkake)");
		//bear;
	}
	
  }
           
//---- done
   return(0);
  }
//+------------------------------------------------------------------+