Measure Trends Function

Measure Trends Function
Download ALL MT5 librarys (391)
YouTube Video Thumbnail



Similar MetaTrader Tools

Measure Trends Function

Info

The Measure Trends Function is a Library for MetaTrader 5 that this function measures trend strength as a percentage, aiding in determining the direction of a previously formed trend for indicator creation. The ideal trend illustration (downtrend on the left, uptrend on the right) shows conditions for an ideal trend.

Usage

This tool is typically used for trend following strategies across multiple currency pairs.

Platform

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

Setup

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


How to Install and Use Measure Trends Function

1. Storage: Place library files in the MQL/Libraries directory to ensure they are accessible to your projects.

2. Implementation: Include the library in your code using the #import directive, ensuring you match the exact function names and parameters.

3. Compilation: Ensure the library is present in the directory before you compile your main EA or script, as the compiler links them during this phase.

4. Management: Keep libraries organized in sub-folders if you manage many custom functions to maintain a clean project structure.

Frequently Asked Questions

Q: What is a library file used for? A: Libraries store reusable code modules, allowing you to centralize common logic used by multiple EAs or indicators.

Q: Is a library executable? A: No, libraries are non-executable files containing functions; they must be imported into an EA, indicator, or script to function.

Q: Can I update a library while the platform is running? A: You should compile your EA or script after updating a library to ensure the latest code changes are integrated.

What this tool does

This function measures trend strength as a percentage, aiding in determining the direction of a previously formed trend for indicator creation.

Typical Use Case

This Library excels in trend following on MetaTrader 5.

Compatible Platform & Setup

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

Description & Settings

Related: binary flags - another powerful library for MetaTrader 5 traders.

This function measures trend strength as a percentage, aiding in determining the direction of a previously formed trend for indicator creation.

Also recommended: class Сbmp button transparent - similar library with strong performance on MetaTrader 5.


The ideal trend illustration (downtrend on the left, uptrend on the right) shows conditions for an ideal trend.

The algorithm uses a rating system, assigning 'balls' for each true condition. These ratings are calculated and converted to a percentage by dividing by the maximum possible value and multiplying by 100%.

The function is available in func_trend.mqh.

An alternative analysis method involves non-uniform rating accrual, with more important conditions receiving higher ratings. This is achieved through a power-of-two rating system, where more critical conditions have higher powers of two.

The updated illustration shows numerous conditions for each trend, with more important ones listed first. These conditions are integrated into the functions, altering the rating calculation while maintaining the trend percentage, as seen in func_trend_2.mqh.

You may also like: Heiken Ashi Smoothed Indicator Trading Signals Module - excellent alternative for library users on MetaTrader 5.

Source Code

#property copyright "robotfx"
#property link "https://robotfx.org"
double func_trend_2(char trend, //trend direction, up=1, down=-1
                    double cop1, // open price of candle 1
                    double cop2, // open price of candle 2
                    double cop3, // open price of candle 3
                    double ccp1, // close price of candle 1
                    double ccp2, // close price of candle 2
                    double ccp3, // close price of candle 3
                    double chp1, // high price of candle 1

.......

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.