//+------------------------------------------------------------------+
//|                Fozzy Daily Indicator                           |
//|                Programmed by Aidrian O'Connor                  |
//|                http://www.unitone.org            |
//+------------------------------------------------------------------+
#property copyright "Fozzy"
#property link      "http://"

#property indicator_chart_window
// #property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 SkyBlue
#property indicator_color2 SkyBlue
#property indicator_color3 Blue
#property indicator_color4 Red

//---- indicator parameters
extern int    RSIPeriod = 8;
extern int    RSIMAPeriod = 8;
extern int    BandsPeriod=20;
extern int    BandsShift=0;
extern double BandsDeviations=2.0;

//---- buffers
double RSI[];
double RSIMA[];
double SignalUP[];
double SignalDN[];
int i;
   
int init()
  {
  IndicatorBuffers(4);
 
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexDrawBegin(0,i-1);
   SetIndexBuffer(0, RSI);
//   SetIndexLabel(0,"RSI");

   SetIndexStyle(1,DRAW_NONE);
   SetIndexDrawBegin(1,i-1);
   SetIndexBuffer(1, RSIMA);
//   SetIndexLabel(1,"RSI-MA");
   
   SetIndexStyle(2,DRAW_ARROW, EMPTY, 2); 
   SetIndexDrawBegin(2,i-1);
   SetIndexBuffer(2, SignalUP);
   SetIndexArrow(2,233);
//   SetIndexLabel(2,"Signal");

   SetIndexStyle(3,DRAW_ARROW, EMPTY, 2); 
   SetIndexDrawBegin(3,i-1);
   SetIndexBuffer(3, SignalDN);
   SetIndexArrow(3,234);
//   SetIndexLabel(3,"Signal");

   return(0);
  }

int start()
  {
   IndicatorShortName("Fozzy");  
   i=Bars-BandsPeriod;
   while(i>=0) {
     RSI[i] = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);
   i--;
   }
   
   i=Bars-BandsPeriod;
   while(i>=0) {
     RSIMA[i] = iMAOnArray(RSI,0,RSIMAPeriod,0,MODE_SMA,i);
   i--;
   }
   
   i=Bars-BandsPeriod;
         
   while(i>=0) {
      //Signal[i] = -100;
      if(RSI[i]>RSIMA[i] && RSI[i+1]<RSIMA[i+1]){
         SignalUP[i] = Low[i] - Point * 25;
      } else {
         if(RSI[i]<RSIMA[i] && RSI[i+1]>RSIMA[i+1]){
            SignalDN[i] = High[i] + Point * 25;
         }
      }
      
   i--;
   }
   Comment("");
   return(0);
  }
 
//+------------------------------------------------------------------+