My custom indicator displays NOTHING

 

Have been trying to develop my first customer indicators.

One example sort of worked and I could access the results - great.

The following displays nothing in the indicator window - not even the ShortName, parameters - just a complete blank panel

I have simplified (and simplified) by removing code so probably isn't too meaningful - just a graph of the HIGH for 2 symbols.

I wanted to use an array My_Buffers so I could handle a variable number of symbols.

I obviously have got something fundamental wrong but can't see it at the moment.

I put a comment in the indicator - just to see if it was displayed ( at the start of of the main body - it showed so the indicator is loading and trying to do something)

Help please!

#property indicator_separate_window
//#property indicator_chart_window    // Indicator is drawn in the main window
#property indicator_buffers 2           // Number of buffers
#property indicator_color1 White         // Color of the 1st line
#property indicator_color2 Yellow      // Color of the 2nd line

string   Instrument_Symbol[35];        // list of all available symbols eg AUDUSD
int      Instrument_Pointer[35];       // list of required symbols eg firts item contains 5 which points to AUDUSD
string   My_Symbol = "";
double   My_Buffers[][7];
double   Buf_0[],Buf_1[];   // Declaring arrays (for indicator buffers)
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
   SetIndexLabel(0,"My_FX");
   IndicatorShortName("My_FX_Indicator");
   SetIndexBuffer(0,Buf_0);                        // White 
   SetIndexStyle (0,DRAW_LINE,STYLE_DOT,1);        // Line style
   SetIndexBuffer(1,Buf_1);                        // Yellow
   SetIndexStyle (1,STYLE_SOLID,1);                // Line style// Line style
   Instrument_Definitions();                       // sets up matrices - only needed ONCE
   return(0);
}
//+------------------------------------------------------------------+
int start()
{  int   i;                           // Bar index
   int   Counted_bars;                // Number of counted bars
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   i=Bars-Counted_bars-1;           // Index of the first uncounted
   while(i>=0 )  
   {  for (int i1 =1; i1 < Instrument_Pointer [0]+1; i1++) 
      {  My_Symbol         = Instrument_Symbol[Instrument_Pointer[i1]];  // eg Instrument_Pointer[1]=5, Instrument_Symbol[5]=AUDUSD 
         My_Buffers[i][i1] = iHigh (My_Symbol,PERIOD_M1,i+1);
      }
      Buf_0[i]             = My_Buffers[i][1];  // AUDUSD 
      Buf_1[i]             = My_Buffers[i][2];  // EURUSD
      i--;                          // Calculating index of the next bar
   }
//--------------------------------------------------------------------
   return;                          // Exit the special funct. start()
}
//+------------------------------------------------------------------+
//==============Instrument_Definitions -- START======================+
void Instrument_Definitions()
{  Instrument_Pointer [0] = 7;   // 7 entries - enties 8 to 34 are o zero
   Instrument_Pointer [1] = 5;   // remainder at bottom of routine
   //.........etc
   Instrument_Symbol  [1] = "AUDCAD";
   Instrument_Symbol  [2] = "AUDCHF";
   Instrument_Symbol  [3] = "AUDJPY";
   Instrument_Symbol  [4] = "AUDNZD";
   Instrument_Symbol  [5] = "AUDUSD";
   Instrument_Symbol  [6] = "CADCHF";
   Instrument_Symbol  [7] = "CADJPY";
 
My_Buffers first dimension has no size
 
zzuegg:
My_Buffers first dimension has no size

Many thanks.

The buffers used for the 'buffers' don't appear to need dimensions i.e. Buf_0[]

But My_Buffers does need the dimension!

I just left the second dimension as 7 and added an 5000 for the first and I get something! [2 almost horizontal lines plus shortname and parameters]

 

Indeed, the internal buffers used for drawing are sized automatically once you 'SetIndexBuffer()' them.

For manual managed buffers you need to do all yourself. Including shifting on a new bar and so on

 
zzuegg:

Indeed, the internal buffers used for drawing are sized automatically once you 'SetIndexBuffer()' them.

For manual managed buffers you need to do all yourself. Including shifting on a new bar and so on



Thanks more difficult than I first thought
 
May i ask what you try to do? 99% of the indicators and calculations do not need a moredimensional array
 
zzuegg:
May i ask what you try to do? 99% of the indicators and calculations do not need a moredimensional array

Thanks for asking.

I'll send a PM to you.

 
At a glance I can see many things wrong in this code. The array declaration is correct but you should use ArrayResize(My_Buffers,20); or something to set the dimension before you use it. Also stick a comment in like this Comment("x= ",Buf_0[0]," y= ",Buf_1[0]);

after you think you have filled the buffers and you will find they are zero. There is no draw_line in the second buffer declaration etc.

If this is your second indicator I would suggest you make it more simple and build on working code.

 
Ruptor:
At a glance I can see many things wrong in this code. The array declaration is correct but you should use ArrayResize(My_Buffers,20); or something to set the dimension before you use it. Also stick a comment in like this Comment("x= ",Buf_0[0]," y= ",Buf_1[0]);

after you think you have filled the buffers and you will find they are zero. There is no draw_line in the second buffer declaration etc.

If this is your second indicator I would suggest you make it more simple and build on working code.

Thanks for your comments.

Following suggestions from zzuegg I have decided to avoid using the 2 dimensional array.

Typically I use Comment() statements frequently or FileWrite but removed many lines of surplus coding for this posting.

Reason: