You use 2 property indicator buffers so you should declare them too.
Try to add this on init
SetIndexBuffer(1, Temp);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1, Lime);
SetIndexLabel(1, "Temp");
see if it works.
BTW, the "HL" line is overwritten by the "Temp" line by this code
Temp[i] = HL[i];
Try to change it like this
Temp[i] = HL[i] + 15*Point;
You use 2 property indicator buffers so you should declare them too.
Try to add this on init
SetIndexBuffer(1, Temp);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1, Lime);
SetIndexLabel(1, "Temp");
see if it works.
BTW, the "HL" line is overwritten by the "Temp" line by this code
Temp[i] = HL[i];
Try to change it like this
Temp[i] = HL[i] + 15*Point;
Hi onewithzachy,
Thank you for your quick reply.
I have tried to add SetIndex...() in the init();
and modified the start() as following
int start()
{
......
......
HL[i] = High[i] - Low[i]; //Correct value
Temp[i] = HL[i] + 0; //Always ZERO
Temp[i] = High[i] - Low[i]; //Always ZERO too
Print(Temp[i]
}
Just don't know what happen!!
Thank you.
All right,
Did you print the "Temp" and the value still zero or empty ?
lets try this one : Open Data Window (click "View" select "Data Window" or press Ctrl + D). See if there's data value of "Temp".
If there's not, well ... i don't understand then, it should work by now.
Maybe you should attach the indy here, or practice yourself by making other simple indy like making indy based on MA.
I mean from all info you gave here, you make no mistake.
All right,
Did you print the "Temp" and the value still zero or empty ?
lets try this one : Open Data Window (click "View" select "Data Window" or press Ctrl + D). See if there's data value of "Temp".
If there's not, well ... i don't understand then, it should work by now.
Maybe you should attach the indy here, or practice yourself by making other simple indy like making indy based on MA.
I mean from all info you gave here, you make no mistake.
Hi onewithzachy,
I have notice that after modified the above codes, i forgot to change the #property indicator_buffer from 1 to 2.
Right now, everything is fine. Thank you for you help.
Wishes
Ken
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have encountered the following errors while writing my indicator:
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
double HL[];
double Temp[];
int init()
{
SetIndexBuffer(0, HL);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, Red);
SetIndexLabel(0, "HL Range");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars = IndicatorCounted();
int i = 0;
if(counted_bars < 0) return(0);
if(counted_bars > 0) counted_bars--;
limit = Bars - counted_bars - 1;
for(i=limit; i>=0; i--)
{
HL[i] = High[i] - Low[i] //<-- CORRECT VALUE returned;
Temp[i] = HL[i]; //<-- NOTHING HAPPEN
Print(Temp[i]); //<-- Always print nothing
}
return(0);
}
Can anyone told me is this a MT4 bug or my program has problem?
Thank you
Ken