Price_Compare - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources

This small cross-platform library allows for easy and fast comparison of "double" values of "price".
For example, before setting SellLimit, it is sometimes useful to check if the open price is lower than the current bid price.
// if (NormalizeDouble(OpenPrice, Digits()) >= NormalizeDouble(Bid, Digits())) // This method is the most commonly used method If (CP(opening price) >= bid ) // Now you can do this and the order is sent ...;
Not only is this cleaner and more concise than standard type checking, but it also performs several times faster! This efficient use of computing resources sometimes results in significant improvements to the tester/optimizer.
You can also set the precision with which "double" values are compared. For example
If ((CP(lot, 0.01 ) >= minimum lot) && ((CP(lot, 0.01 ) <= maximum lot))) // Compare the order to the second decimal place after the decimal point to send ...;
All comparison operators (==, !=, >=, <=, >, <) are handled in a similar manner.
This library contains faster methods for normalized double precision execution. In order to improve the execution speed of standard functions, just add the following content at the beginning
// Almost four times faster than the corresponding standard function (build 1395) #Define normalized double PRICE_COMPARE::MyNormalizeDouble
As an example, the attached script shows the results of the comparison and normalization methods for different price values.

Attachment download
📎 examplecompare.mq5 (1.02 KB)
📎 price_compare.mqh (2.5 KB)
Source: MQL5 #16169
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •