Discussing the article: "Creating Custom Indicators in MQL5 (Part 1): Building a Pivot-Based Trend Indicator with Canvas Gradient"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Creating Custom Indicators in MQL5 (Part 1): Building a Pivot-Based Trend Indicator with Canvas Gradient.
In this article, we create a Pivot-Based Trend Indicator in MQL5 that calculates fast and slow pivot lines over user-defined periods, detects trend directions based on price relative to these lines, and signals trend starts with arrows while optionally extending lines beyond the current bar. The indicator supports dynamic visualization with separate up/down lines in customizable colors, dotted fast lines that change color on trend shifts, and optional gradient filling between lines, using a canvas object for enhanced trend-area highlighting.
We will build the indicator’s architecture on a clear separation of responsibilities: input parameters, indicator buffers, and graphical properties. We will begin by defining the key inputs, such as fast/slow periods, colors, opacity, arrow code, and extensions, which will dictate the behavior of the indicator. We will then allocate eight buffers to store slow-up/down lines, fast lines with colors, trend arrows with colors, and internal calculations for trend/slow values. These buffers will be linked to graphical plots, with properties such as type (line/color line/arrow), color, width, and shift configured using MQL5’s built-in functions. Additionally, we will use the canvas class to fill the space between lines with gradients, ensuring the indicator adapts dynamically to market volatility. In a nutshell, here is an example of what we will be getting.
Author: Allan Munene Mutiiria