Func Measure Trends - MetaTrader 5 Library - MT4/MT5 Resources


Since the creation of the indicator requires the determination of the direction of the previously formed trend in order to further solve the algorithm, I came up with a certain formula that measures the strength of the trend (how close the trend is to the ideal) in percentage.
The diagram below symbolizes, in my opinion, the ideal trend (downtrend on the left, uptrend on the right). Next to each trend are indicated the conditions under which the ideal trend exists:

First, to write this function, I decided to go into a rating system, i.e. for each real condition there would be some " ball " variable that gets a rating. These ratings are further formed into this variable and after final calculation of the ratings, the number of ratings received is divided by the maximum possible number and then multiplied by 100% so that the ratings received can be converted into a percentage.
Actually the function itself is in function_trend . mqh.
Then I came up with another idea, which is non-uniform accumulation of ratings. For example, for the most important criteria, more ratings will be accumulated. So the idea of using the power of 2 to calculate ratings came up. The more important the condition, the higher the power of 2.
The illustrations below show a number of conditions for each trend. The more important conditions are at the beginning of the list:

Conditions are added to the function and the significance of calculating the ratings changes, but the overall trend percentage remains the same. This can be seen in function_trend_2 . mqh.
Attachment download
📎 func_trend.mqh (2.76 KB)
📎 func_trend_2.mqh (3.41 KB)
Source: MQL5 #1506
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •