How to properly understand "indicator_buffers"?

 

“indicator_buffers    int    Number of buffers for indicator calculation"

How should understand correctly?For example, MACD indicators, we only see "MACD" and "Signal" in MT5, but why are "#property indicator_buffers 4" written in MQL5?

#property indicator_buffers 4

thank you

 
Because 2 buffers are visible but 2 others are needed for the calculation.
 
Alain Verleyen:
Because 2 buffers are visible but 2 others are needed for the calculation.
//--- indicator buffers
double                   ExtMacdBuffer[];
double                   ExtSignalBuffer[];
double                   ExtFastMaBuffer[];
double                   ExtSlowMaBuffer[];
//--- MA handles
int                      ExtFastMaHandle;
int                      ExtSlowMaHandle;
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtFastMaBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,ExtSlowMaBuffer,INDICATOR_CALCULATIONS);

For example, the MACD index, you need 4 arrays and SetIndexBuffer, which is indicator_buffers4, right?

 
helloea:

For example, the MACD index, you need 4 arrays and SetIndexBuffer, which is indicator_buffers4, right?

Yes.

 
Seng Joo Thio:

Yes.

How do I know how they work?

//--- indicator buffers
double                   ExtMacdBuffer[];
double                   ExtSignalBuffer[];
double                   ExtFastMaBuffer[];
double                   ExtSlowMaBuffer[];
//--- MA handles
int                      ExtFastMaHandle;
int                      ExtSlowMaHandle;
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtFastMaBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,ExtSlowMaBuffer,INDICATOR_CALCULATIONS);
 
helloea:

How do I know how they work?

I don't exactly know what you mean, but I assume you've checked the MQL5 online docs? If so, then my answer will be to "experiment"... that's the best way to understand how anything works.

 
Seng Joo Thio:

I don't exactly know what you mean, but I assume you've checked the MQL5 online docs? If so, then my answer will be to "experiment"... that's the best way to understand how anything works.

Yes, I've looked at the documentation, and I've looked at it more than once, but I don't know how to figure out what each function means, which is hard to understand in the documentation, but how to experiment with each function?Thanks for telling me

 
helloea:

Yes, I've looked at the documentation, and I've looked at it more than once, but I don't know how to figure out what each function means, which is hard to understand in the documentation, but how to experiment with each function?Thanks for telling me

Generic answer is to "vary inputs, run function, and check outputs".

Do you have any programming background? For instance, do you recognize variable types and their declarations, functions, operators, pre-processors, etc. when you first look at them and you know the purposes each of them serve in general? because if you have programming background, then using a debugger should not be a problem?

If so, then perhaps you can start by using the debugger in the metaeditor of mt5 - step through lines that you don't understand, one at a time, check the changes in variable values as each line is processed, and from there devise ways to further experiment on functions you don't quite understand, and see how outcomes change according to different inputs.

 
Seng Joo Thio:

Generic answer is to "vary inputs, run function, and check outputs".

Do you have any programming background? For instance, do you recognize variable types and their declarations, functions, operators, pre-processors, etc. when you first look at them and you know the purposes each of them serve in general? because if you have programming background, then using a debugger should not be a problem?

If so, then perhaps you can start by using the debugger in the metaeditor of mt5 - step through lines that you don't understand, one at a time, check the changes in variable values as each line is processed, and from there devise ways to further experiment on functions you don't quite understand, and see how outcomes change according to different inputs.

good idea. I feel like I have a lot to do, but it's great to have your help

Reason: