Files
xMQL4/Docs/Samples/indicator_buffers.md
T
2024-01-25 04:03:36 +03:30

1.3 KiB

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

#property indicator_buffers numOfBuffers

for example:

#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.

#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.

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;
}