Help with chart clutter please

 
As a beginner finally I have managed to put together a simple code for identifying certain candle stick formations. However, as it can be seen in the chart picture provided after changing time frames within the the same currency pair or just waiting in the same time frame of the currency pair object texts get cluttered and writes on top of each other. Is there a way to fix them to their bars and progress back as time goes by. Thank you in advance for all your help.
//+------------------------------------------------------------------+
//|                                           SKV CANDLES DENEME.mq4 |
//|                                                            SAMIM |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

#property indicator_chart_window

string PatternText[200000];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int N;
   int N1;
   int N2;
   int counter;
   
   for(int j = 0; j < Bars; j++) 
     { 
       PatternText[j] = "pattern-" + j;
     }
   for(N = 0; N < Bars; N++) 
     {
     
       counter = N;
       N1= N + 1;
       N2= N + 2;   
//WHITE HAMMER       
       if (((Close[N]>Open[N]) && ((Open[N]-Low[N])>=2*(Close[N]-Open[N])) &&
       ((High[N]-Close[N])<=(Open[N]-Low[N])*0.10))) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], Low[N] - 5*Point);
       ObjectSetText(PatternText[N], "HMR", 8, "Arial", MediumBlue);
       }
//BLACK HAMMER       
       if (((Close[N]<Open[N]) && ((Close[N]-Low[N])>=2*(Open[N]-Close[N])) &&
       ((High[N]-Open[N])<=(Close[N]-Low[N])*0.10))) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], Low[N] - 5*Point);
       ObjectSetText(PatternText[N], "HMR", 8, "Arial", MediumBlue);
       }
//WHITE SHOOTING STAR       
       if (((Close[N]>Open[N]) && ((High[N]-Close[N])>=2*(Close[N]-Open[N])) && 
       ((Open[N]-Low[N])<=(High[N]-Close[N])*0.10))) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + 30*Point);
       ObjectSetText(PatternText[N], "STR", 8, "Arial", Gold);    
       }   
//BLACK SHOOTING STAR
       if (((Close[N]<Open[N]) && ((High[N]-Open[N])>=2*(Open[N]-Close[N])) && 
       ((Close[N]-Low[N])<=(High[N]-Open[N])*0.10))) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + 30*Point);
       ObjectSetText(PatternText[N], "STR", 8, "Arial", Gold);
       }
//BULLISH ENGULFING       
       if (((Close[N1]<Open[N1]) && ((Close[N]>Open[N])) && 
       ((Open[N]<Close[N1]) && (Close[N]>Open[N1])))) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], Low[N] - 5*Point);
       ObjectSetText(PatternText[N], "ENG", 8, "Arial", MediumBlue);
       }
//BEARISH ENGULFING       
       if (((Close[N1]>Open[N1]) && ((Close[N]<Open[N])) && 
       ((Open[N]>Close[N1]) && (Close[N]<Open[N1])))) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + 30*Point);
       ObjectSetText(PatternText[N], "ENG", 8, "Arial", Gold);
       }
//PIERCING       
       if ((Close[N1]<Open[N1]) && (Close[N]>Open[N]) && 
       (Open[N]<Close[N1]) && (   Close[N]>(      ((Open[N1]-Close[N1])/2)+Close[N1])  )&& (Close[N]<=Open[N1]))
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], Low[N] - 5*Point);
       ObjectSetText(PatternText[N], "PRC", 8, "Arial", MediumBlue);
       }
//DARK CLOUD       
       if ((Close[N1]>Open[N1]) && (Close[N]<Open[N]) && 
       (Open[N]>Close[N1]) && (   Close[N]<(      ((Close[N1]-Open[N1])/2)+Open[N1])  )&& (Close[N]>=Open[N1]))
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + 30*Point);
       ObjectSetText(PatternText[N], "CLD", 8, "Arial", Gold);
       }
//BULLISH HARAMI       
       if ((Close[N1]<Open[N1]) && ((MathAbs(Close[N]-Open[N]))<(0.25*(Open[N1]-Close[N1]))) && 
       (Close[N]<Open[N]) && (Open[N]<Open[N1]) && (Close[N]>Close[N1]))
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], Low[N] - 5*Point);
       ObjectSetText(PatternText[N], "HAR", 8, "Arial", MediumBlue);
       }
//BEARISH HARAMI       
       if ((Close[N1]<Open[N1]) && ((MathAbs(Close[N]-Open[N]))<(0.25*(Open[N1]-Close[N1]))) && 
       (Close[N]>Open[N]) && (Open[N]>Close[N1]) && (Close[N]<Open[N1]))
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + 30*Point);
       ObjectSetText(PatternText[N], "HAR", 8, "Arial", Gold);
       }
//BULLISH SASH       
       if ((Close[N1]<Open[N1]) && (Open[N]>Close[N1]) && (Close[N]>Open[N1])) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], Low[N] - 5*Point);
       ObjectSetText(PatternText[N], "SAH", 8, "Arial", MediumBlue);
       }
//BEARISH SASH      
      if ((Close[N1]>Open[N1]) && (Open[N]<Close[N1]) && (Close[N]<Open[N1])) 
       {      
       ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + 30*Point);
       ObjectSetText(PatternText[N], "SAH", 8, "Arial", Gold);
       }
       
    }
   
   return(0);
}
//+------------------------------------------------------------------+

 
Previously asked and answered Help with HAMMER code please - MQL4 forum
 
svezir:
....object texts get cluttered and writes on top of each other. Is there a way to fix them to their bars and progress back as time goes by. Thank you in advance for all your help.
Hi Svezir,

It looks like you have solved the Object Names problem with Raptor's and Whroeder's help in your previous post...and your candle code appears to work fine...so I may not understand your current question.

If you are asking how to adjust your text over and under the candles...to minimize or prevent the "clutter" on top of the candles...

I would add the following user settings:

extern int BullDist = 1000;
extern int BearDist = 500;

Then replace all your "5" under and "30" over with the externs...

One Example:

Original - ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + 30*Point);
Revised - ObjectCreate(PatternText[N], OBJ_TEXT, 0, Time[N], High[N] + BullDist*Point);

I used large numbers above to start with...so they stay readable when you switch to higher TF's.

If you use it only on one TF....

The lower the TF frame...the smaller the numbers can be.

Higher TF's need a larger distance number to place them above/below the candles to be readable.

Hope this helps,
Robert
 

Robert,

Thanks for the reply. It is my fault that I have mentioned in my original post to attach a picture witch would describe the difficulty that I was having, but I forgot to attache it. So, I am attaching it here. As you will see that two objects are placed on top of each other, not originally as the indicator is placed on the main chart window, but later on with as time progresses. I hope this would make it more clear for you.



Thank you again,


Svezir

 
svezir:

Robert,

Thanks for the reply. It is my fault that I have mentioned in my original post to attach a picture witch would describe the difficulty that I was having, but I forgot to attache it. So, I am attaching it here. As you will see that two objects are placed on top of each other, not originally as the indicator is placed on the main chart window, but later on with as time progresses. I hope this would make it more clear for you.



Thank you again,


Svezir

Hi Svezir,


I first thought "clutter" meant that the candle names on the candles were unreadable...hence the "distance" settings to move the candle names above or below the candles to see them easier.

However, your clarification and helpful chart examples now show the problem more clearly...so I went back and took another look at Raptor/Whroeder's suggestions for you.

The problem looks like it still may be a "object naming" problem they mentioned...along with how/where the names are added to the chart positions.

I ran the indicator in the Strategy Tester...and did see how it names a candle... However, once started, it does not mark the current candle after it starts, but either changes....or writes on top of the existing past candle names...

Try to revise your code using the examples they gave you...and if you need more help...see Pattern Recognition Master v3 for how it takes care of this problem.

Hope this helps,
Robert
Reason: