How to use ds_Symbol in indicator using C++?

How to create strategies and indicators
Message
Author
stepsy
Posts: 3
Joined: Tue May 19, 2015 7:54 am

How to use ds_Symbol in indicator using C++?

#1 Postby stepsy » Tue May 19, 2015 7:59 am

I'm creating a simple indicator where I want to print text below each bar. However, when I build the code, there is no error but when I run the indicator in ForexTester, nothing appears on the screen either. The code is below.

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


:cry:
Attachments
Capture.PNG
Capture.PNG (38.75 KiB) Viewed 11161 times

Return to “FT API”

Who is online

Users browsing this forum: No registered users and 27 guests