Why are all of my buffers displaying??

 

I have adapted a code to indicate crossovers of RSI and a moving average of RSI on the main chart window. However, I cannot figure out why all of the buffers are being displayed, rather than just the crossover signals. If you look at the attached image, you will see that all of the highs and lows have been connected and although not visible here, the RSI and MA are also being plotted on the main chart window.

I realise that I must be making some sort of basic error in the coding, but haven't a clue where.

I would be very grateful if somebody could explain my error and help me to resolve this issue.

Here is the code:

//+------------------------------------------------------------------+
//|                                                   RSIMA-X-MC.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

//Adapted from original code by Hayseed
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 0

extern int RSI  = 14;        
extern int RSI_MA  = 5;         
extern int MA_MODE = 0;// 0 = sma, 1 = ema, 2 = smma, 3 = lwma
extern int cbars = 0;
extern color UP_ARROW = Green;
extern color DOWN_ARROW = OrangeRed;

double RSIBuffer[];
double MaBuffer[];
double Up[];
double Dn[];
double highP[];
double lowP[];

//*************************************************************************commence initiation
void init()
         {
            //-------------------------------start of buffer indexing
            SetIndexBuffer(0, RSIBuffer);
            SetIndexBuffer(1,MaBuffer);
            SetIndexBuffer(2,Up);
            SetIndexBuffer(3,Dn);
            SetIndexBuffer(4,highP);
            SetIndexBuffer(5,lowP);
            //------------------------------end of buffer indexing
            
            //------------------------------start of buffer display properties
            SetIndexStyle(2,DRAW_ARROW,0,1,UP_ARROW);
            SetIndexArrow(2,164);
            SetIndexEmptyValue(2,0);
            //
            SetIndexStyle(3,DRAW_ARROW,0,1,DOWN_ARROW);
            SetIndexArrow(3,164);
            SetIndexEmptyValue(3,0);
            //-----------------------------end of buffer display properties
            
return(0);
         }
//**************************************************************************initiation complete

//*********************************************************************************************
int deinit()
         {
            //not used
return(0);
         }
//*********************************************************************************************

//******************************************************************************start main code
int start()
         {
            int i,limit = cbars;
            if(limit==0) limit = Bars;
            //----------------------------------------------------------------create RSI values
            for(i=limit-1; i>=0; i--)
               {
                  RSIBuffer[i] = iRSI(NULL,0,RSI,PRICE_CLOSE,i);
               }
            //------------------------------------------------------------------create high values
            for(i=limit-1; i>=0; i--)
               {
                  highP[i] = High[i];
               }
            //-----------------------------------------------------------------create low values
            for(i=limit-1; i>=0; i--)
               {
                  lowP[i] =Low[i];
               }
            //-----------------------------------------------------------------calculate MA of RSI and check for crossover
            for(i=limit-1; i>=0; i--)
               {
                  MaBuffer[i] = iMAOnArray(RSIBuffer,0,RSI_MA,0,MA_MODE,i);
                  
                  if((RSIBuffer[i] - MaBuffer[i])<=0 && (RSIBuffer[i+1] - MaBuffer[i+1]) > 0) {Dn[i]=highP[i]+(highP[i]*0.01);} else {Dn[i]=0;}
                  if((RSIBuffer[i] - MaBuffer[i])>=0 && (RSIBuffer[i+1] - MaBuffer[i+1]) < 0) {Up[i]=lowP[i]-(lowP[i]*0.01);} else {Up[i]=0;}
               }
return(0);
         }
            

Thanks in advance....

 

my guess is that if you don't add a specific draw option the buffer autmaticly become a line.

try:

SetIndexStyle(x,DRAW_NONE);

for all the buffers you don't want to draw.

//z

 
zzuegg:

my guess is that if you don't add a specific draw option the buffer autmaticly become a line.

try:

for all the buffers you don't want to draw.

//z


Thank you very much zzueg - your solution worked.

Cheers

Reason: