Enhance MQL4 Code for Indicators with New Dot Buffers and Logic

Enhance your MQL4 indicator with new buffers for dynamic dot visualization on

Workflow Stage:
Use Case
Save Prompt
Prompt Saved

Overview

This prompt aims to enhance existing MQL4 code by adding new indicator functionalities. Programmers and traders using MetaTrader 4 will benefit from improved visual data representation on their charts.

Prompt Overview

Purpose: This code enhancement aims to add visual indicators for Bullish and Bearish FVG formations on the chart.
Audience: The intended users are traders and developers familiar with MQL4 programming and technical analysis.
Distinctive Feature: New buffers for green, blue, and red dots will be added to enhance chart visualization.
Outcome: The updated code will display additional dots and values in the Data Window, improving trading decision-making.

Quick Specs

Variables to Fill

No inputs required — just copy and use the prompt.

Example Variables Block

No example values needed for this prompt.

The Prompt


You are provided with existing MQL4 code that implements specific indicator functionality. Your task is to enhance this code by adding new buffers and displaying additional dots on the chart as specified below.
**Requirements:**
1. Maintain the existing code and all current functionality without removal or alteration unless necessary for integration.
2. Add buffer index values to appear in the Data Window:
– Add a buffer for a green dot value.
3. Add new dot buffers and display dots for Bullish FVG High and Bearish FVG Low:
– After a Bullish FVG confirmation, identify the Bullish FVG High as the low of the last candle (the third candle) involved in the FVG formation.
– Mark this point with a blue dot on the chart.
– After a Bearish FVG confirmation, identify the Bearish FVG Low as the low of the last candle (the third candle).
– Mark this point with a red dot on the chart.
**Additional details:**
– Use separate buffers for each dot type (green, blue, red).
– Ensure these buffers correspond to properly indexed candles so the dots align visually on the chart.
– The values in the buffers should be set in a manner that they appear correctly in the Data Window and on the price chart.
# Steps
4. Review the existing MQL4 code to understand current buffers and how dots are plotted.
5. Define new buffers for:
– Green dot
– Blue dot (Bullish FVG High)
– Red dot (Bearish FVG Low)
6. Update the `OnInit` function or equivalent to:
– Allocate buffers
– Set their properties
7. In the calculation function (e.g., `OnCalculate`), implement logic to:
– Detect Bullish and Bearish FVG confirmation.
– Mark the Bullish FVG High with a blue dot at the low of the last candle.
– Mark the Bearish FVG Low with a red dot similarly.
– Add the green dot value to its buffer at the appropriate candle.
8. Ensure all buffer values are properly indexed, and values for candles without dots are set to `EMPTY_VALUE`.
9. Confirm that the Data Window displays the new buffers and their values.
# Output Format
Provide the complete, updated MQL4 code with the added buffers and dot plotting logic integrated. The code must compile and run within MetaTrader 4, showing the new green, blue, and red dots correctly aligned with their respective candle points and displaying buffer values in the Data Window.

Screenshot Examples

How to Use This Prompt

  1. Copy the prompt for MQL4 code enhancement.
  2. Review existing MQL4 code for current buffer functionality.
  3. Define new buffers for green, blue, and red dots.
  4. Update the OnInit function to allocate and set buffer properties.
  5. Implement logic in OnCalculate to plot dots for FVG confirmations.
  6. Ensure proper indexing and confirm Data Window displays new buffers.

Tips for Best Results

  • Understand Existing Code: Thoroughly review the current MQL4 code to grasp the existing functionality and buffer structure before making changes.
  • Add New Buffers: Define separate buffers for the green dot, blue dot (Bullish FVG High), and red dot (Bearish FVG Low) to ensure they can be individually managed and displayed.
  • Update Initialization: Modify the `OnInit` function to allocate the new buffers and set their properties, ensuring they are ready for use in the calculation phase.
  • Implement Dot Logic: In the calculation function, add logic to detect FVG confirmations and set the appropriate buffer values for the dots, ensuring they align with the correct candles and are displayed in the Data Window.

FAQ

  • What is MQL4 used for?
    MQL4 is a programming language for developing trading strategies and indicators in MetaTrader 4.
  • How do you add a new buffer in MQL4?
    You declare a new double array and allocate it in the OnInit function using ArraySetAsSeries.
  • What does EMPTY_VALUE represent in MQL4?
    EMPTY_VALUE is used to indicate that no value is set for a specific buffer index.
  • How to plot dots on a chart in MQL4?
    You set the buffer value to the price level where you want the dot to appear.

Compliance and Best Practices

  • Best Practice: Review AI output for accuracy and relevance before use.
  • Privacy: Avoid sharing personal, financial, or confidential data in prompts.
  • Platform Policy: Your use of AI tools must comply with their terms and your local laws.

Revision History

  • Version 1.0 (February 2026): Initial release.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Used Prompts

Related articles

Enhance analytics page with Firebase data and UI improvements.

This guide provides clear steps to integrate data and refine the visual interface.

Improve C++MQL4 Code for Horizontal Line Management

Enhance your coding skills by optimizing financial charting applications.

Enhance Playwright Framework for Reliable User Sign-Ups

Improve automation reliability and maintainability for seamless user registration processes.

Improve financial management app code quality and robustness

This approach strengthens the application's reliability and long-term maintainability.