/*
   Power of Sharing!
   E-mail : knightsof4x@gmail.com
*/

#property indicator_separate_window
#property indicator_levelcolor DarkSlateGray
#property indicator_minimum -1
#property indicator_maximum 1
#property indicator_buffers 7
#property indicator_color1 LimeGreen
#property indicator_color2 OrangeRed
#property indicator_color3 Black


extern int TimeFrame = 0;
extern int RSI1Period = 10;
extern int RSI2Period = 60;
extern int RSIPrice = 0;
extern int MA1Signal = 50;
extern int MA2Signal = 300;
extern int MA1Mode = 2;
extern int MA2Mode = 3;
extern int BarLevel = 0;
extern double RSIHistoModify = 1.5;
double indiBuf1[];
double indiBuf2[];
double indiBuf3[];
double RSILine1[];
double RSIAvg1[];

double RSILine2[];
double RSIAvg2[];





int init() {
   IndicatorBuffers(7);
   SetIndexStyle(0, DRAW_ARROW, 3, 3);
   SetIndexArrow(0, 167);
   SetIndexBuffer(0, indiBuf1);
   SetIndexStyle(1, DRAW_ARROW, 3, 3);
   SetIndexArrow(1, 167);
   SetIndexBuffer(1, indiBuf2);
   
   SetIndexStyle(2, DRAW_ARROW,3,3);
   SetIndexArrow(2, 167);
   SetIndexBuffer(2, indiBuf3);

   SetIndexStyle(3,DRAW_NONE);
   SetIndexStyle(4, DRAW_NONE);
   SetIndexStyle(5, DRAW_NONE);
   SetIndexStyle(6, DRAW_NONE);
   
   SetIndexBuffer(3, RSILine1);
   SetIndexBuffer(4, RSIAvg1);
   SetIndexBuffer(5, RSILine2);
   SetIndexBuffer(6, RSIAvg2);

   return (0);
}

int deinit() {
   return (0);
}

int start() {
  
   int li_16 = IndicatorCounted();
 //  IndicatorShortName("Rumi WaterSkiGuy RSI  Signal " );
   if (li_16 < 0) return (-1);
   if (li_16 > 0) li_16--;
   int li_24 = Bars - 31;
   if (li_16 >= 31) li_24 = Bars - li_16 - 1;
   for (int li_20 = li_24; li_20 >= 0; li_20--) {
      double temp= iRSI(NULL,0,RSI1Period,RSIPrice,li_20);
      RSILine1[li_20] = (iRSI(NULL, TimeFrame, RSI1Period, RSIPrice, li_20) - 50.0)* 1.5;
      RSILine2[li_20] = (iRSI(NULL, TimeFrame, RSI2Period, RSIPrice, li_20) - 50.0) * 1.5; 
   }
   for (li_20 = 0; li_20 < li_24; li_20++) RSIAvg1[li_20] = iMAOnArray(RSILine1, Bars, MA1Signal, 0, MA1Mode, li_20);
   for (li_20 = 0; li_20 < li_24; li_20++) RSIAvg2[li_20] = iMAOnArray(RSILine2, Bars, MA2Signal, 0, MA2Mode, li_20);
   for (li_20 = 0; li_20 < li_24; li_20++) {
       if ((RSIAvg1[li_20] < RSILine1[li_20]) && (RSIAvg2[li_20] < RSILine2[li_20])) indiBuf1[li_20]=BarLevel;		
            else  if ((RSIAvg1[li_20] > RSILine1[li_20]) && (RSIAvg2[li_20] > RSILine2[li_20])) indiBuf2[li_20]=BarLevel;
	                    else indiBuf3[li_20]=BarLevel;	        	 
   }	
   
  return (0);
}

