54 lines
1.3 KiB
Markdown
54 lines
1.3 KiB
Markdown
# Buffers
|
|
|
|
simply they are arrays which store information for using them as series in candles ...
|
|
in each mql program you had to define which buffers youi have to use in your program.
|
|
|
|
this happens by the following pattern
|
|
|
|
```mq4
|
|
#property indicator_buffers numOfBuffers
|
|
```
|
|
|
|
for example:
|
|
|
|
```mq4
|
|
#property indicator_buffers 2
|
|
```
|
|
here we define 2 buffer to system for processing in each candle ...
|
|
|
|
then we have to define arrays ...
|
|
|
|
double BufferFast[];
|
|
double BufferSlow[];
|
|
|
|
usually for each indicator buffers we can define a constant to hold it's index on chart queue.
|
|
|
|
```mq4
|
|
#define FastIndicator 0
|
|
#define SlowIndicator 1
|
|
```
|
|
|
|
each buffer holds data to use in candle calculation time and then draw things on chart.
|
|
|
|
we have to define Indexes for Buffers to draw themon chart.
|
|
this happens on OnInit() event handler method.
|
|
|
|
```mq4
|
|
int OnInit() {
|
|
//
|
|
// Fast Indicator ...
|
|
SetIndexStyle(FastIndicator, DRAW_LINE, STYLE_DOT, 1, clrFireBrick);
|
|
SetIndexBuffer(FastIndicator, BufferFast);
|
|
SetIndexLabel(FastIndicator, "Fast");
|
|
|
|
//
|
|
// Slow Indicator ...
|
|
SetIndexStyle(SlowIndicator, DRAW_LINE, STYLE_DOT, 1, clrGreen);
|
|
SetIndexBuffer(SlowIndicator, BufferSlow);
|
|
SetIndexLabel(SlowIndicator, "Slow");
|
|
|
|
//
|
|
return INIT_SUCCEEDED;
|
|
}
|
|
```
|