Help me with GRAALUn_Ar nrp-Histro indicator

 

Hello friends, please I need help with the Graalun indicator.

It is giving error of array out of range error. Below is the indicator code. Thanks.

string gral_name=" ";
string s_symbol,s_id,s_gral;

double  ExtBuffer0[];
double  ExtBuffer1[];
double  ExtBuffer2[];
double  ExtBuffer3[];

//double arrow_down[];
//double arrow_up[];

bool flag_last_trend,flag_arr_up,flag_arr_dn,flag_start_max_search;
double last_trend,max_value;
int k;

datetime time_alert_buy,time_alert_sell;
int whichBar = 0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4);
   
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
   SetIndexBuffer(3,ExtBuffer3);

   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   
   SetIndexLabel(0,"line");
   SetIndexLabel(1,"arr");
   SetIndexLabel(2,"dn");
   SetIndexLabel(3,"up");
   
   IndicatorDigits(Digits);

   s_symbol=Symbol();
   s_id=s_symbol+" "+fTimeFrameName(0);
   s_gral=gral_name+s_id;

   IndicatorShortName(" ");

   time_alert_buy=0;
   time_alert_sell=0;

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
{
   deleteArrows(s_gral);
   return(0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars;
   double Value0=0,Value1=0,Fish0=0,Fish1=0,Fish2=0,Fish3=0,Value00=0,Value11=0;
   double price;
   double MinL=0;
   double MaxH=0;
   bool   up = true;

   counted_bars=IndicatorCounted();

   if(counted_bars>0)
      counted_bars--;
   limit=Bars-counted_bars;

   for(int i = shift; i<limit; i++)
   {
      MaxH = High[iHighest(NULL,0,MODE_HIGH,period,i)];
      MinL = Low[iLowest(NULL,0,MODE_LOW,period,i)];
      price = (High[i]+Low[i])/2;

      if(MaxH-MinL == 0)
         Value00 = 0.33*2*(0-0.5) + 0.67*Value0;
      else
         Value00 = 0.33*2*((price-MaxH)/(MinL-MaxH)-0.5) + 0.67*Value0;

      if(1-Value00==0)
         ExtBuffer0[i]=0.5+0.5*Fish0;
      else
         ExtBuffer0[i]=-0.5*MathLog((1+Value00)/(1-Value00))+0.5*Fish0;

      Value00=MathMin(MathMax(Value00,-0.999),0.999);

      Value0=Value00;
      Fish0=ExtBuffer0[i];

      if(MaxH-MinL==0)
         Value11=0.33*2*(0-0.5)+0.67*Value1;
      else
         Value11=0.33*2*((price-MaxH)/(MinL-MaxH)-0.5)+0.67*Value1;

      Value11=MathMin(MathMax(Value11,-0.999),0.999);

      if(1-Value11==0)
         ExtBuffer1[i]=0.5+0.5*Fish1;
      else
         ExtBuffer1[i]=-0.5*MathLog((1-Value11)/(1+Value11))+0.5*Fish1;

      Value1=Value11;
      Fish1=ExtBuffer1[i];
      
      Fish2=ExtBuffer0[i];
      Fish3=ExtBuffer1[i];

      if (((Fish2<0)&&(Fish3<0))||(Fish2<0))   up = false;    
      if (((Fish2>0)&&(Fish3>0))||(Fish2>0))   up = true;
      
      if(!up)
        {
         ExtBuffer2[i]=Fish2;
         ExtBuffer3[i]=0;
        }
        
       else
        {
         ExtBuffer3[i]=Fish2;
         ExtBuffer2[i]=0;
        }
      
     }

   flag_last_trend=false;
   k=0;
   flag_start_max_search=false;
   last_trend=0;
   max_value=0;

   for(int i = shift; i<nbars; i++)
   {
      flag_arr_up=false;
      flag_arr_dn=false;
      if(ExtBuffer1[i]>0 && ExtBuffer1[i+1]<=0)
      {
         if (show_arrow == true)
         create_arrow(s_gral+TimeToString(Time[i]),High[i]+arrow_shift*Point,Time[i],226,3,clrRed,ANCHOR_BOTTOM);else
         create_arrow(s_gral+TimeToString(Time[i]),High[i]+arrow_shift*Point,Time[i],226,3,clrNONE,ANCHOR_BOTTOM);
         if(!flag_last_trend)
         {
            k=i;
            flag_start_max_search=true;
            last_trend=-1;
            max_value=ExtBuffer1[i];
         }
         flag_last_trend=true;
         flag_arr_dn=true;
      }
      if(ExtBuffer1[i]<0 && ExtBuffer1[i+1]>=0)
      {
         if (show_arrow == true)
         create_arrow(s_gral+TimeToString(Time[i]),Low[i]-arrow_shift*Point,Time[i],225,3,clrBlue,ANCHOR_TOP);else
         create_arrow(s_gral+TimeToString(Time[i]),Low[i]-arrow_shift*Point,Time[i],225,3,clrNONE,ANCHOR_TOP);
         if(!flag_last_trend)
         {
            k=i;
            flag_start_max_search=true;
            last_trend=1;
            max_value=ExtBuffer1[i];
         }
         flag_last_trend=true;
         flag_arr_up=true;
      }
      if(flag_start_max_search && i>k)
      {
         if(last_trend<0)
         {
            if(flag_arr_up)
               flag_start_max_search=false;
            else
               if(ExtBuffer0[i]>=max_value)
                  max_value=ExtBuffer0[i];
         }
         if(last_trend>0)
         {
            if(flag_arr_dn)
               flag_start_max_search=false;
            else
               if(ExtBuffer0[i]<=max_value)
                  max_value=ExtBuffer0[i];
         }
      }
   }

   int i = shift;
   if(alertsOn)
   {
      if((ExtBuffer1[i]>0 && ExtBuffer1[i+1]<=0) && (time_alert_sell!=Time[0]))
      {
         doAlert(whichBar," - SELL");
         time_alert_sell=Time[0];
      }
      if((ExtBuffer1[i]<0 && ExtBuffer1[i+1]>=0) && (time_alert_buy!=Time[0]))
      {
         doAlert(whichBar," - BUY");
         time_alert_buy=Time[0];
      }
   }

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void create_arrow(string name,double price,datetime time,int arrow_code,int width,color _color,ENUM_ARROW_ANCHOR _anchor)
  {
   if(ObjectFind(0,name)<0)
     {
      ObjectCreate(0,name,OBJ_ARROW,0,0,0);
     }
   ObjectSetDouble(0,name,OBJPROP_PRICE,price);
   ObjectSetInteger(0,name,OBJPROP_TIME,time);
   ObjectSetInteger(0,name,OBJPROP_ARROWCODE,arrow_code);
   ObjectSetInteger(0,name,OBJPROP_WIDTH,width);
   ObjectSetInteger(0,name,OBJPROP_COLOR,_color);
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,_anchor);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void deleteArrows(string arrowsIdentifier_)
  {
   string lookFor       = arrowsIdentifier_;
   int    lookForLength = StringLen(lookFor);
   for(int i_=ObjectsTotal()-1; i_>=0; i_--)

     {
      string objectName=ObjectName(i_);
      if(StringSubstr(objectName,0,lookForLength)==lookFor)
         ObjectDelete(objectName);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string fTimeFrameName(int arg)
  {
   if(arg==0)
     {
      arg=Period();
     }
   switch(arg)
     {
      case 0:
         return("0");
      case 1:
         return("M1");
      case 2:
         return("M2");
      case 5:
         return("M5");
      case 15:
         return("M15");
      case 30:
         return("M30");
      case 60:
         return("H1");
      case 240:
         return("H4");
      case 1440:
         return("D1");
      case 10080:
         return("W1");
      case 43200:
         return("MN1");
      default:
         return("M"+IntegerToString(arg));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void doAlert(int forBar, string doWhat)
  {
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;

   if(previousAlert != doWhat || previousTime != Time[forBar])
     {
      previousAlert  = doWhat;
      previousTime   = Time[forBar];

      message =  StringConcatenate(" ",s_id," ",doWhat);
      if(alertsMessage)
         Alert(message);
      if(alertsNotify)
         SendNotification(message);
      if(alertsEmail)
         SendMail(StringConcatenate(Symbol(), Period(), WindowExpertName()),message);
      if(alertsSound)
         PlaySound(soundFile);
     }
  }
//+------------------------------------------------------------------+

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL4 programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Documentation.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2023.11.22
  • www.mql5.com
The largest freelance service with MQL5 application developers
 

Dont bother ok?

I am a coder, how do you know I am not a coder?

I have found the error and solved it. I dont need your freelance service you are advertising to me. Thank you

 
kennymic1 #: Dont bother ok? I am a coder, how do you know I am not a coder? I have found the error and solved it. I dont need your freelance service you are advertising to me. Thank you

No, It does not seem plausible to consider you a coder, because:

  1. You asked for help with an array out of range error, which a decent coder would immediately know how to fix and would not need any help.
  2. Your profile shows that you have a long history of hiring Freelance coders, which would contradict your statement.

So, the normal conclusion would be to assume you are not a coder.

Also, I was not advertising my freelance services, as I have no interest in it. But if you have fixed your issue, then good for you!

Reason: