Custom indicator help

 

I have been trying to add a custom BB_PRC-1 indicator in my Ea, it gets displayed but the values of the lines are empty.

Indicator works fine, and displays correct values in data window. But when i try to get values with iCustom  i get 0 or EMPTY values for both lines... can you help me?




My code is:

double red_line = iCustom(_Symbol, _Period, "BB_PRC-1",  bPer, bDev,maPer, maMeth, useAlerts, alertBar, alertSleep, 0,1 );
double yellow_line = iCustom(_Symbol, _Period, "BB_PRC-1",  bPer, bDev,maPer, maMeth, useAlerts, alertBar, alertSleep, 1,1 );
   



and BB_PRC-1 indicator:

//+------------------------------------------------------------------+
//|                                                       BB_PRC.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
#property indicator_color1 Red
#property indicator_color2 Gold
#property indicator_buffers 2

double bol[];
double ma[];
extern int bPer=20,bDev=2,maPer=50,maMeth=MODE_EMA;
extern bool useAlerts=true;
extern int alertBar=1;
extern int alertSleep=1800;//in seconds
int lastAlert;
#property indicator_separate_window

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,bol);
   SetIndexStyle(0,DRAW_LINE,EMPTY,2);

   SetIndexBuffer(1,ma);
   SetIndexStyle(1,DRAW_LINE,EMPTY,1);

   IndicatorShortName("BB PRC RANGE v1");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars-bPer;

   for(int i=0; i<=limit;i++)
     {
      double bandL=iBands(Symbol(),0,bPer,bDev,0,PRICE_CLOSE,MODE_MINUSDI,i);
      double bandH=iBands(Symbol(),0,bPer,bDev,0,PRICE_CLOSE,MODE_PLUSDI,i);
      bol[i]=((Close[i]-bandL)/(bandH-bandL));

      if((Close[i]-bandL)==0 || (bandH-bandL)==0)
         Print(i," ",(Close[i]-bandL)," ",(bandH-bandL));
     }

   for(int j=0; j<=limit;j++)
     {
      ma[j]=iMAOnArray(bol,0,maPer,0,maMeth,j);
     }

   if(useAlerts)
     {
      if(ma[alertBar]>=bol[alertBar] && CurTime()>lastAlert && (bol[2+alertBar]>=bol[1+alertBar]) && (bol[1+alertBar] < bol[alertBar]))
        {
         Alert("BB PRC MADE LOW "+ Symbol() + " on the " +  Period() + " minute chart.");
         lastAlert=CurTime()+alertSleep;
        }

      if(ma[alertBar]<=bol[alertBar] && CurTime()>lastAlert && (bol[2+alertBar]<=bol[1+alertBar]) && (bol[1+alertBar] > bol[alertBar]))
        {
         Alert("BB PRC MADE HIGH "+ Symbol() + " on the " +  Period() + " minute chart.");
         lastAlert=CurTime()+alertSleep;
        }

      if(CurTime()>lastAlert && bol[alertBar+1]>=ma[alertBar+1] && bol[alertBar] < ma[alertBar])
        {
         Alert("BB PRC CROSSED MA FOR SELL "+ Symbol() + " on the " +  Period() + " minute chart.");
         lastAlert=CurTime()+alertSleep;
        }

      if(CurTime()>lastAlert && bol[alertBar+1]<=ma[alertBar+1] && bol[alertBar] > ma[alertBar])
        {
         Alert("BB PRC CROSSED MA FOR BUY "+ Symbol() + " on the " +  Period() + " minute chart.");
         lastAlert=CurTime()+alertSleep;
        }
     }

   return(0);
  }
//+------------------------------------------------------------------+
 
Josip Marić:

I have been trying to add a custom BB_PRC-1 indicator in my Ea, it gets displayed but the values of the lines are empty. can you help me?




My code is:



and BB_PRC-1 indicator:


@ Josip Marić

 int init()
  {
//---- indicators
   SetIndexBuffer(0,bol);
   SetIndexStyle(0,DRAW_LINE,EMPTY,2);
   SetIndexEmptyValue(0,0.0);
   
   SetIndexBuffer(1,ma);
   SetIndexStyle(1,DRAW_LINE,EMPTY,1);
   SetIndexEmptyValue(1,0.0);
   IndicatorShortName("BB PRC RANGE v1");
//----
   return(0);
  }
 
Mehmet Bastem:


@ Josip Marić


Thank you, but i get 0 values now:


 
double red_line = iCustom(_Symbol, _Period, "BB_PRC-1",  bPer, bDev,maPer, maMeth, useAlerts, alertBar, alertSleep, 0,1 );
double yellow_line = iCustom(_Symbol, _Period, "BB_PRC-1",  bPer, bDev,maPer, maMeth, useAlerts, alertBar, alertSleep, 1,1 );

There is nothing wrong with this program.

Maybe there is a problem in some other part, but who knows?

Try the attached program.


Files:
 
Nagisa Unada:

There is nothing wrong with this program.

Maybe there is a problem in some other part, but who knows?

Try the attached program.


No luck, i get empty indicator window with your program...

 
Please help....
 
Josip Marić:

No luck, i get empty indicator window with your program...

My program is not designed to display lines, so it will only display an empty window.

It's impossible to help you, because no one has ever seen your program.

 
Nagisa Unada:

My program is not designed to display lines, so it will only display an empty window.

It's impossible to help you, because no one has ever seen your program.

I just wanted to import this indi above in an empty EA, and i have printed values... but they are 0


here you go.. my program:


//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict


extern int bPer=20,bDev=2,maPer=50,maMeth=MODE_EMA;
extern bool useAlerts=true;
extern int alertBar=1;
extern int alertSleep=1800;//in seconds
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

   double red_line = iCustom(_Symbol, _Period, "BB_PRC-1",  bPer, bDev,maPer, maMeth, useAlerts, alertBar, alertSleep, 0,1 );
   double yellow_line = iCustom(_Symbol, _Period, "BB_PRC-1",  bPer, bDev,maPer, maMeth, useAlerts, alertBar, alertSleep, 1,1 );
   PrintFormat("red line(%g), yellow line(%g)", red_line, yellow_line);
      
   
  }
//+------------------------------------------------------------------+
Files:
BB_PRC-1.mq4  4 kb
 
Josip Marić:

I just wanted to import this indi above in an empty EA, and i have printed values... but they are 0


here you go.. my program:


First of all, your indicator is wrong. The return "Buffers" value does not exist. Also the bar does not follow. Your indicator has been corrected and the Expert has been re-adjusted. Good luck with. new old indicators

 
Mehmet Bastem:

First of all, your indicator is wrong. The return "Buffers" value does not exist. Also the bar does not follow. Your indicator has been corrected and the Expert has been re-adjusted. Good luck with.

Thank you so much!
 
Mehmet Bastem:

First of all, your indicator is wrong. The return "Buffers" value does not exist. Also the bar does not follow. Your indicator has been corrected and the Expert has been re-adjusted. Good luck with.

Your corrected version doesnt display correct... second line is missing...


Reason: