//+------------------------------------------------------------------+
//|                                                   StochCross.mq4 |
//|                      Copyright © 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

extern int K = 15;
extern int D = 3;
extern int Slow = 2;
extern int Ma_Method = 0;
// true = 1 false = 0;
extern string Note = "CloseClose true will use the CloseClose settings for Stoch. False will use High/Low";
extern bool CloseClose = true;
double UP[];
double DOWN[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
SetIndexBuffer(0,UP);
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,4);
SetIndexArrow(0,241);

SetIndexBuffer(1,DOWN);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,4);
SetIndexArrow(1,242);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  } 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
   int i,Counted_bars;               // Number of counted bars
   Counted_bars=IndicatorCounted(); // Number of counted bars
   i=Bars-Counted_bars-1;           // Index of the first uncounted
   while(i>=0)                      // Loop for uncounted bars
     {
      
      if(iStochastic(Symbol(),0,K,D,Slow,Ma_Method,CloseClose,1,i+1)>80 && iStochastic(Symbol(),0,K,D,Slow,Ma_Method,CloseClose,1,i) < 80) DOWN[i] = High[i] + 60*Point;
      if(iStochastic(Symbol(),0,K,D,Slow,Ma_Method,CloseClose,1,i+1)<20 && iStochastic(Symbol(),0,K,D,Slow,Ma_Method,CloseClose,1,i) > 20) UP[i] = Low[i] - 60*Point ;
      
      i--;                          
     }

  
   return(0);
  }
//+------------------------------------------------------------------+