In the screenshot, what I want to create is an indicator that highlights candles where the open and the close are close to each other.
Code: Select all
//---------------------------------------------------------------------------
// Body Range Ratio indicator
//---------------------------------------------------------------------------
#include <windows.h>
#include "IndicatorInterfaceUnit.h"
#include "TechnicalFunctions.h"
// Buffers
TIndexBuffer RBRatioBuffer;
//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
EXPORT void __stdcall Init()
{
// define properties
IndicatorShortName("RB Ratio");
SetOutputWindow(ow_ChartWindow);
IndicatorBuffers(1); // -- defines the number of visible arrays
RBRatioBuffer = CreateIndexBuffer(); // -- create an index buffer. returns TIndexBuffer (class tow ork with index buffers) to access array of data.
SetIndexBuffer(0, RBRatioBuffer);
SetIndexStyle(1, ds_Symbol, psSolid, 20, clYellow);
SetIndexLabel(1, "RB Ratio");
SetIndexSymbol(1, 218, 0, 0);
}
EXPORT void __stdcall OnParamsChange() //-- SetBufferShift in this fxn. This procedure should be called in the OnParamsChange procedure if the shift parameter is defined in the parameters of the indicator. If the shift is static value, this procedure can be called in the Init procedure.
{
SetBufferShift(0, 15); // -- Set the index buffer shift in bars.
}
//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
EXPORT void __stdcall Calculate(int index)
{
RBRatioBuffer[index] = 1;
}