Req correction in code

 

Hello friends this is checkmail and am having an nice working indicator expect it gives an compilation error, and also it doesn't function as coded.

The indicator is to change the bars as per the trend blue for uptrend and red for downtrend, to improve its accuracy the first bar of both the trends is to be painted as yellow for confirmation of change in trend.

As normally all indicators do repaint, thats why we wait for one bar of the new trend to close completely to get an accurate signal.

But am having some error with it, the past data looks good but the current data is drawn a kind sloppy can say repainting or malfunctioning.

Can anybody point out and fix the coding error of this indicator.

Here is the code :

#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Yellow

extern int period = 18;
extern bool Add_vertical_line = FALSE;
extern color Vertical_line_color_long = Blue;
extern color Vertical_line_color_short = Red;
extern bool Alert.Sound = TRUE;
extern bool Alert.Email = FALSE;
extern int Number_of_bars_to_calculate=5000;
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double changeBuf[];
static datetime lastbar = 0;
double prevtime;
string gs_92 = "";
string gs_error_100 = "error ind";
int array_count = 0;
string objNames[];

int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID,0);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID,2);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID,2);
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID,2);
   IndicatorDigits(Digits + 1);
   SetIndexBuffer(0, g_ibuf_80);
   SetIndexBuffer(1, g_ibuf_84);
   SetIndexBuffer(2, g_ibuf_88);
   SetIndexBuffer(3, changeBuf);
   IndicatorShortName(gs_error_100);
   SetIndexLabel(1, NULL);
   SetIndexLabel(2, NULL);
   SetIndexLabel(3, NULL);
   ArrayResize(objNames,Number_of_bars_to_calculate);
   prevtime=Time[0];
   return (0);
}

int deinit() {
  int items=ArrayRange(objNames,0)-1; 
  int i = 0;
   for (i=items; i>=0;i--) {
      if(objNames[i] != "") {
         ObjectDelete(objNames[i]);
      }      
   }
   return (0);
}

int start() {
   double ld_0;
   double ld_8;
   double ld_16;
   int li_24 = IndicatorCounted();
   double ld_28 = 0;
   double ld_36 = 0;
   double ld_unused_44 = 0;
   double ld_unused_52 = 0;
   double ld_60 = 0;
   double ld_unused_68 = 0;
   double l_low_76 = 0;
   double l_high_84 = 0;
   int pos = 0;
   creataalltext();
   int li_92 = 16777215;
   if (li_24 > 0) li_24--;
   int li_96 = Bars - li_24;
   for (int li_100 = 0; li_100 < li_96; li_100++) {
      l_high_84 = High[iHighest(NULL, 0, MODE_HIGH, period, li_100)];
      l_low_76 = Low[iLowest(NULL, 0, MODE_LOW, period, li_100)];
      ld_16 = (High[li_100] + Low[li_100]) / 2.0;
      ld_28 = 0.66 * ((ld_16 - l_low_76) / (l_high_84 - l_low_76) - 0.5) + 0.67 * ld_36;
      ld_28 = MathMin(MathMax(ld_28, -0.999), 0.999);
      g_ibuf_80[li_100] = MathLog((ld_28 + 1.0) / (1 - ld_28)) / 2.0 + ld_60 / 2.0;
      ld_36 = ld_28;
      ld_60 = g_ibuf_80[li_100];
   }
   bool li_104 = TRUE;
//   if (NewBar()) {
      for (li_100 = li_96 - 2; li_100 >= 0; li_100--) {
         ld_8 = g_ibuf_80[li_100+1];
         ld_0 = g_ibuf_80[li_100 + 2];
   
         if ((ld_8 < 0.0 && ld_0 > 0.0) || ld_8 < 0.0) li_104 = FALSE;
         if ((ld_8 > 0.0 && ld_0 < 0.0) || ld_8 > 0.0) li_104 = TRUE;
         
   
         if (!li_104) {
            gs_92 = "SHORT";
            li_92 = 65535;

         } else {
            gs_92 = "LONG";
            li_92 = 65280;
         }
        
         if (ld_8 >= 0.0) {
            g_ibuf_84[li_100+1] = ld_8;
            g_ibuf_88[li_100+1] = EMPTY_VALUE;
         }
         if (ld_8 < 0.0) {
            g_ibuf_84[li_100+1] = EMPTY_VALUE;
            g_ibuf_88[li_100+1] = ld_8;
         }
         if (ld_8 <= 0.0 && ld_0 > 0.0) {
            changeBuf[li_100+1] = -2.5;//ArrayMaximum(g_ibuf_84,100);
            if ( (Add_vertical_line) && (pos < Number_of_bars_to_calculate) ) {
               AddVLine(li_100+1,Vertical_line_color_short);
               pos++;
            }
            g_ibuf_84[li_100+1] = EMPTY_VALUE;
            g_ibuf_88[li_100+1] = EMPTY_VALUE;
            if (prevtime != Time[0]) {  
               if (Alert.Sound) {
                  Alert("Error: Short signal on " + Symbol() + "!");
                  PlaySound("Alert.wav");
               }
               if (Alert.Email) SendMail("Error", "Error: Short signal on " + Symbol() + "!");
               prevtime = Time[0];
            }
         }
         
         if (ld_8 >= 0.0 && ld_0 < 0.0) {
            changeBuf[li_100+1] = 2.5;//ArrayMinimum(g_ibuf_88,100);
            if ( (Add_vertical_line) && (pos < Number_of_bars_to_calculate) ) {
               AddVLine(li_100+1,Vertical_line_color_long);
               pos++;
            }
            g_ibuf_84[li_100+1] = EMPTY_VALUE;
            g_ibuf_88[li_100+1] = EMPTY_VALUE;
            if (prevtime != Time[0]) {  
               if (Alert.Sound) {
                  Alert("Error: Long signal on " + Symbol() + "!");
                  PlaySound("Alert.wav");
               }
               if (Alert.Email) SendMail("Error", "Error: Long signal on " + Symbol() + "!");
               prevtime = Time[0];
            }
         }
      }
      settext("Error_ind2", gs_92, 12, li_92, 10, 15);
//   }
   return (0);
}

bool NewBar()
{

   datetime curbar = Time[0];
   if(lastbar!=curbar) {
      lastbar=curbar;
      return (true);
   }
   else {
      return(false);
   }
}  
void creataalltext() {
   createtext("Error_ind2");
   settext("Error_ind2", "", 12, White, 10, 15);
}

void createtext(string a_name_0) {
   ObjectCreate(a_name_0, OBJ_LABEL, WindowFind(gs_error_100), 0, 0);
}

void settext(string a_name_0, string a_text_8, int a_fontsize_16, color a_color_20, int a_x_24, int a_y_28) {
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_24);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_28);
   ObjectSetText(a_name_0, a_text_8, a_fontsize_16, "Arial", a_color_20);
}

void AddVLine(int pos,color linecol) {
   if(ObjectFind(TimeToStr(Time[pos]))==-1) {
      if(!ObjectCreate(TimeToStr(Time[pos]), OBJ_VLINE, 0, Time[pos], 0)) {
         return(0);
      } 
      else {
         objNames[array_count] = TimeToStr(Time[pos]);
         ObjectSet(TimeToStr(Time[pos]), OBJPROP_STYLE, STYLE_DOT);
         ObjectSet(TimeToStr(Time[pos]), OBJPROP_COLOR, linecol);
         array_count++;       
      }
   }
}
         
Files:
error.mq4  6 kb
 
decompiled (maybe stolen) indicator
 

it's a decompiled indicator

regardless

there is no such thing it doesn't function as coded.

 

Hello friends this is checkmail and the indicator functions nearly well and its not any stolen, but is on an forum, without few modifications(vertical line, etc stuffs) kindly.

If can find error be to the best, else don't go on singing any horror tune here, not atleast on this post.

 
checkmail:

Hello friends this is checkmail and the indicator functions nearly well and its not any stolen, but is on an forum, without few modifications(vertical line, etc stuffs) kindly.

If can find error be to the best, else don't go on singing any horror tune here, not atleast on this post.


even like this is decompiled and illegal because is against copyright .. not to think about some good sense to the original author..

 
EADeveloper:


even like this is decompiled and illegal because is against copyright .. not to think about some good sense to the original author..

Hello EADeveloper this is checkmail and am trying to optimize the usage of this indicator as got interested by its consistency in drawing bars without falling for fake signals.

Well the indicator do have an author, but can't reveal it as this indicator is already modified from the original version.And finally and most important its not for selling purpose but to develop future indicator

which doesn't fall for fake signals.

In modification it contains the vertical line, yellow bar(divider), signal text, etc stuff means the indicator was hardly observed by anybody.

If you can find the missing code it might help me a bit.

Reason: