About" indicator_testor EURUSD,M5: array to be set is of incompatible type "

 

The code is very simple, but I can't understand why MT4's expert complain that "array to be set is of incompatible type"

My codes are as below:

#property indicator_separate_window
int counted=0;

#property indicator_buffers 2
#property indicator_color1 Silver

int i[2];
datetime current_time[];

int init()
  {
   IndicatorBuffers(2);
   SetIndexBuffer(0, i);
   SetIndexBuffer(1, current_time);
   return(0);
   }

int deinit()
  {
   return(0);
  }

int start()
  {
   int    counted_bars=IndicatorCounted();
if(counted<2)
{
i[0]=0;
i[1]=1;
current_time[0]=TimeCurrent();
Print("current_time[2], current_time[1], current_time[0], i[0] and i[1] are: ",TimeToStr(current_time[2],TIME_DATE|TIME_SECONDS)," ",TimeToStr(current_time[1],TIME_DATE|TIME_SECONDS)," ",TimeToStr(current_time[0],TIME_DATE|TIME_SECONDS)," ",i[0]," and ",i[1]);
Sleep(1000*10);

counted++;
}
   return(0);

  }

Another question is that: if I change the first line of the codes to be "indicator_chart_window" from "indicator_separate_window"; if the codes are executed normally, and attached to some pair, whether the bars will become very small because of this Indicator's buffer array---current_tiime[] has big value?

 

You are using SetIndexBuffer all wrong, search for examples.

buffers can't be declared with a size

buffers must be doubles only

why would you have current time as a buffer?!

How do you have 100 posts and still not know this?

Read more before you start coding. Make sure you know better what you are doing and what you are using. Stop posting annoying questions.

Just sit down.. and study. Properly. Don't ask every detail so that 5 people waste their time on something you should already have discovered yourself.

I'm sorry to be so harsh but I know what many Chinese people are like.. give an inch and they take a mile 得寸进尺 .. so that's it. No more inches from me.

 
vx0532:

The code is very simple, but I can't understand why MT4's expert complain that "array to be set is of incompatible type"

My codes are as below:

Another question is that: if I change the first line of the codes to be "indicator_chart_window" from "indicator_separate_window"; if the codes are executed normally, and attached to some pair, whether the bars will become very small because of this Indicator's buffer array---current_tiime[] has big value?

What alladir said bears repeating . . .


Please read the documentation before asking questions . . . the fastest way to get help is to help yourself first.

SetIndexBuffer() the array specified when you use SetIndexBuffer() is type double . . . bool SetIndexBuffer(int index, double array[])


 

hha,

Thanks, RaptorUK.

 
vx0532:

hha,

Thanks, RaptorUK.

And thank you alladir . . .
 

hha,

Thanks, RaptorUK.

 
vx0532:

hha,

Thanks, RaptorUK.


Haha, ok, if you have a sense of humour all is forgiven
 
alladir:

You are using SetIndexBuffer all wrong, search for examples.

buffers can't be declared with a size buffers can be declared with a size, in the fact and I have try to do that, it is well; I use iCustom() to get this value which is contained in the Indicator in Start(); If can't, how we can get the value which we want to use ?

buffers must be doubles only

why would you have current time as a buffer?!

How do you have 100 posts and still not know this?

Read more before you start coding. Make sure you know better what you are doing and what you are using. Stop posting annoying questions.

Just sit down.. and study. Properly. Don't ask every detail so that 5 people waste their time on something you should already have discovered yourself.

I'm sorry to be so harsh but I know what many Chinese people are like.. give an inch and they take a mile 得寸进尺 .. so that's it. No more inches from me.

 

vx0532


buffers can be declared with a size, in the fact and I have try to do that, it is well; I use iCustom() to get this value which is contained in the Indicator in Start(); If can't, how we can get the value which we want to use ?

Buffers are single dimension arrays[] of the double type. They are set as buffers using SetIndexBuffer(). They are automatically sized and indexed so it is pointless trying to size them yourself. Whatever size you give them will be overruled when you call SetIndexBuffer(). There are thousands of indicators in the codebase to see as examples.

bool SetIndexBuffer(int index, double array[])
Parameters:
index - Line index. Must lie between 0 and 7.
array[] - Array that stores calculated indicator values.
Sample:
  double ExtBufferSilver[];
  int init()
    {
      SetIndexBuffer(0, ExtBufferSilver); // first line buffer
      // ...
    }
 
Reason: