one of three buffers is hidden

 
Hello

I have just coded this:

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Red
#property  indicator_color2  Blue
#property  indicator_color3  Green
//----
extern int RSIPeriod1=14;
extern int RSIPeriod2=28;
extern int Cross1=10;
extern int Cross2=10;
extern double coefficient=2.0;

double   MABuffer1[];
double   Cross1Buffer[];
double   Cross2Buffer[];

double DSS, delta, HighRange, LowRange, smooth_coefficient;

int init()
  {
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(2, DRAW_LINE);

   SetIndexBuffer(0, MABuffer1);
   SetIndexBuffer(1, Cross1Buffer);
   SetIndexBuffer(2, Cross2Buffer);
   
   smooth_coefficient = coefficient / (1.0 + RSIPeriod1);
   
   return(0);
  }

int start()
  {
   double RSI1,RSI2;

   int  Limit, i, counted_bars = IndicatorCounted();
//----
   if(counted_bars < 0) 
       return(-1);
//----
   if(counted_bars > 0) 
       counted_bars--;
   Limit=ArraySize(MABuffer1);
   for(i=Limit; i>=0; i--) 
   {
     RSI1 = iRSI(NULL, 0, RSIPeriod1, PRICE_OPEN, i);
     RSI2 = iRSI(NULL, 0, RSIPeriod2, PRICE_OPEN, i);

     MABuffer1[i] = (RSI1-RSI2);
     
   }
   
   
      
   
   for(i=Limit; i>=0; i--)
     {
      Cross1Buffer[i]=iMAOnArray(MABuffer1,Bars,Cross1,0,MODE_EMA,i);
     } 
   
   for(i=Limit; i>=0; i--)
     {
      HighRange = Cross1Buffer[ArrayMaximum(Cross1Buffer, Cross2, i)];
      LowRange = Cross1Buffer[ArrayMinimum(Cross1Buffer, Cross2, i)];
      delta = Cross1Buffer[i] - LowRange;
      DSS = delta/(HighRange - LowRange)*100.0;
      Cross2Buffer[i] = smooth_coefficient * (DSS - Cross2Buffer[i+1]) + Cross2Buffer[i+1];
     } 
   
   
   return(0);
}

It shows the red and the blue line, but not the green one!
What is wrong with my code? Can you help me?

Thanks


leMai
 
   for(i=Limit; i>=0; i--) Cross2Buffer[i]=0;
   for(i=Limit-MathMax(RSIPeriod1,RSIPeriod2); i>=0; i--)
     {

      HighRange = Cross1Buffer[ArrayMaximum(Cross1Buffer, Cross2, i)];
      LowRange = Cross1Buffer[ArrayMinimum(Cross1Buffer, Cross2, i)];
      delta = Cross1Buffer[i] - LowRange;
      DSS = delta/(HighRange - LowRange)*100.0;
      Cross2Buffer[i] =smooth_coefficient * (DSS - Cross2Buffer[i+1]) + Cross2Buffer[i+1];
     } 
Try this code..
 
fai:
Try this code..


Thank you very much, it works :-)


leMai
 
Unfortunatelly I don't understand why I have to use MathMax and now I wanted to try the same thing with another indicator, and it didn't work because I don't have two extern ints, I only have one.
So what now?

int start()

  {   Draw4HowLong = Bars-Rperiod - 5;
      length = Rperiod;
      loopbegin = Draw4HowLong - length - 1;
      int Limit=ArraySize(ExtMapBuffer1); 
      
      for(shift = loopbegin; shift >= 0; shift--)
      { 
         sum[1] = 0;
         for(i = length; i >= 1  ; i--)
         {
         lengthvar = length + 1;
         lengthvar /= 3;
         tmp = 0;
         tmp = ( i - lengthvar)*Close[length-i+shift];
         sum[1]+=tmp;
         }
         wt[shift] = sum[1]*6/(length*(length+1));           
        
         ExtMapBuffer1[shift] = wt[shift];
      }
      
      
  
     for(i=Limit; i>=0; i--) ExtMapBuffer2[i]=0;
     for(i=Limit-MathMax(Rperiod,Rperiod); i>=0; i--)
      {

       HighRange = ExtMapBuffer1[ArrayMaximum(ExtMapBuffer1, Cross, i)];
       LowRange  = ExtMapBuffer1[ArrayMinimum(ExtMapBuffer1, Cross, i)];
       delta = ExtMapBuffer1[i] - LowRange;
       DSS = delta/(HighRange - LowRange)*100.0;
       ExtMapBuffer2[i] =smooth_coefficient * (DSS - ExtMapBuffer2[i+1]) + ExtMapBuffer2[i+1];
      }
      
Now the value of ExtMapBuffer1 is huge and very flat, but ExtMapBuffer2 is just a line!

Thanks for you help



leMai
Reason: