Indicator sample

Browse HighLowIndicator sample source code or download in a ZIP file

Indicators are MQL programs that attach to the chart and allow drawing graphs related to the chart. NQuotes supports indicators creation using .NET. An indicator is represented by an MQL file (*.mq4) and an associated .NET class.

The indicator line is drawn by specifying the Y coordinate in "indicator buffer". The buffer is an array that is filled by your indicator code in the "start" MQL function. The X coordinate is the buffer index, that is buf[X] = Y. The .NET class doesn't have a direct access to this buffer, so the idea is to copy the data from .NET into this buffer in the MQL code. Follow the HighLowIndicator sample code, and see the MQL functions reference for the documentation.

The HighLowIndicator sample shows how to build a simple indicator using C#. You can find the sample source code in the "%TERMINAL_DATA_PATH%\MQL4\Projects\nquotes\HighLowIndicator" folder.

  1. Copy the MQL file "HighLowIndicator.mq4" into the indicators folder - "%TERMINAL_DATA_PATH%\MQL4\Indicators", and compile using the MetaEditor (metaeditor.exe).
  2. Build the indicator Visual Studio project (HighLowIndicator.sln). It has a single class "HighLowIndicator.cs".
  3. Run the project in debugger. It will start "DebugHost.exe" and wait for the terminal.
  4. Start the MT4 terminal (terminal.exe) and attach the indicator to the chart.