Please point out my mistake.

 

I use an indicator which shows a value as the object.

The value is calculated on the closed prices for the appointed period as the parameter. 

I added some code lines to make it time series chart as below.

But it does not work well. 

Actually it works only as it is.

But does not when the period is changed.

What is wrong?

In the original code...... 

<*1>  double he is declared as variable, not array.

<*2>  price[i] = Close[i].  j is not declared, no for statement neither. 

<*3> he = a. 

#include <MyLib.mqh>
#include <HE.mqh>

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_width1 STYLE_SOLID
#property indicator_level1 0.5

extern int HEPeriod = 20;

double he[];            // *1

int init()
{
   IndicatorBuffers(1);   
   SetIndexBuffer(0, he);
   
   return(0);
}

int start()
{
        int i, j, limit = Bars - IndicatorCounted();
        double price[];

        ArrayResize(price, HEPeriod);

        for(j = limit - 1; j >= 0; j--)
        {
                for(i = 0; i <= HEPeriod - 1; i++)
                {
                        price[i] = Close[i + j];                // *2
                }

///////////////////////////////////////////////////////////////////////////

/* Exisiting code lines in which <double a> is declared.                 */
/* The original program shows the value of the <double a> as the object. */

///////////////////////////////////////////////////////////////////////////

        he[j] = a;		// *3
        }

        return (0);
}



 
Allot of things wrong. *double he[], never sized. *double loops un-necessary. *price[i] never used. *variable a never defined. Perhaps you should make price[i] the buffer. *codes does not compile. *what's within the include_file *why are they needed *did you learn to code using the mql4 book.
 
ubzen:
Allot of things wrong. *double he[], never sized. 
There is no need,  it's an Indicator buffer . . .   I think some of the code is not shown,  for example how  a  is calculated . . .
 
RaptorUK:
There is no need,  it's an Indicator buffer . . .   I think some of the code is not shown,  for example how  a  is calculated . . .
K my mistake. Do you have a good idea what he wants? My thinking is he's trying to assign Close[i + j] to i_buffers.
 
ubzen:
K my mistake. Do you have a good idea what he wants? My thinking is he's trying to assign Close[i + j] to i_buffers.
I'm not sure we can see without all the code . . .
 

Thank you for the reply.

I made price[] the indicator buffer as ubzen's suggestion.

But it does not work.

It could not work because I am not so skilled.

But why it works as it is?

I cannot change the period  neither on the chart with changing the parameter nor on the editor with changing the number.

I do not think the number of 20 means anything. 

 

Does this work? Is it what you're looking for?

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_width1 STYLE_SOLID
#property indicator_level1 0.5

extern int HEPeriod = 20;
double he[];

int init(){
   IndicatorBuffers(1);   
   SetIndexBuffer(0, he);
   return(0);
}

int start(){
    int limit=Bars-IndicatorCounted()-1;
    for(int j=limit; j>=0; j--){
        for(int i=0; i<HEPeriod; i++){
            he[i] = Close[i + j];
    }   }
    return(0);
}
Reason: