new bar event handler for indicators

new bar event handler for indicators
Download ALL MT5 indicators (5742)
YouTube Video Thumbnail



Similar MetaTrader Tools

new bar event handler for indicators

Info

The new bar event handler for indicators is a Indicator for MetaTrader 5 that the idea of this approach is described in the new bar event handler article. the example of its use in the expert advisors is presented in the article.

Usage

This tool is typically used for enhancing chart analysis and decision making.

Platform

This Indicator works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Indicators folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use new bar event handler for indicators

1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.

2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.

3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.

4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.

Frequently Asked Questions

Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."

Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).

Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.

What this tool does

the idea of this approach is described in the new bar event handler article.

Typical Use Case

This Indicator excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Indicator works on MetaTrader 5. Place the file in the MQL5/Indicators folder and restart the terminal.

Description & Settings

Related: Ease of Movement Technical Indicator - another powerful indicator for MetaTrader 5 traders.

the idea of this approach is described in the new bar event handler article. the example of its use in the expert advisors is presented in the article. here you will find the solution for the indicators. the idea is the same: it will allow to perform recalculations only when the new bar has appeared. it's a convenient alternative to the direct use of the oncalculate function.

Also recommended: investors vs speculators delta - similar indicator with strong performance on MetaTrader 5.


here is a simple indicator, it prints a line when the new bar has appeared:

the indicator uses the onnewbarcalculate function to handle the new bar event. this function is called only when a new bar appears, not at every tick.

the onnewbarcalculate function takes several parameters, including the total number of rates, the previous calculated value, and arrays of time, open, high, low, close, tick volume, volume, and spread values.

in this function, you can write the code similar to oncalculate, but it will be called only if a new bar has appeared. the function returns the value of prev_calculated for the next call.

- the indicator is a convenient tool for performing calculations only when a new bar appears.
- it uses the onnewbarcalculate function to handle the new bar event.
- the function takes several parameters, including the total number of rates and arrays of time and price values.



title text

the new bar event handler for indicators is a useful tool for traders who want to perform calculations only when a new bar appears. it's a convenient alternative to the direct use of the oncalculate function and can be used in a variety of trading strategies.

- the indicator is easy to use and requires minimal setup.
- it can be used in combination with other indicators and trading strategies.
- the onnewbarcalculate function is called only when a new bar appears, making it a efficient way to perform calculations.

You may also like: center of gravity ht f - excellent alternative for indicator users on MetaTrader 5.

Source Code

#property copyright "robotfx"
#property link "https://robotfx.org"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
#include <onnewbarcalculate.mqh> // here is the secret of call of onnewbarcalculate() function
int onnewbarcalculate(const int rates_total,
                      const int prev_calculated,
                      const datetime &time[],

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.