How do I go through an enumeration consistently? - page 4

 
fxsaber:
Almost four times faster than standard NormalizeDouble (build 1395)... is a crutch of the developers.

What's almost four times faster? Show me the code!
 
I'm surprised about the 4 times, too...
And it's not really clear how arrays or switch fall down there. It's pure mathematics.
 
Dmitry Fedoseev:
What's almost four times faster? Give me the code!
There's no telling how many days in the codebase for inspection. The checker must be on holiday.
 
fxsaber:
In the kodobaza for an inspection for an unknown number of days. The inspector is probably on holiday.
I think they started posting it today. Maybe they will come to us too ))))
 
Ihor Herasko:
I think they started posting it today. Maybe they will reach us too ))))
You got it. I don't.
 
Dmitry Fedoseev:
What's almost 4 times faster? Code, please!

https://www.mql5.com/ru/code/16169

// Почти в четыре раза быстрее соответствующей стандартной функции (build 1395)
#define NormalizeDouble PRICE_COMPARE::MyNormalizeDouble
Price_Compare
Price_Compare
  • votes: 1
  • 2016.08.25
  • fxsaber
  • www.mql5.com
Изящное и шустрое сравнение double-значений "цены".
 

Be careful when using this function, it will work correctly on a smaller range of values than NormalizeDouble.

I won't explain why - guess for yourself.

The NormalizeDouble function works :

  1. The integer part is selected - I
  2. Fractional part is selected - F
  3. F = F * 10^digits
  4. F = F (+ or - depending on the sign) 0.5
  5. F = (integer part of F) / 10^digits
  6. result = I + F
 
All in all, there was no sensation.
 
Ilyas:

Be careful when using this function, it will work correctly on a smaller range of values than NormalizeDouble.

I won't explain why - guess for yourself.

The NormalizeDouble function works :

  1. The integer part is detected - I
  2. Fractional part is selected - F
  3. F = F * 10^digits
  4. F = F (+ or -, depending on the sign) 0.5
  5. F = (integer part from F) / 10^digits
  6. result = I + F

The function description contains the following note

Calculated StopLoss and TakeProfit values, as well as values of open prices for pending orders should be normalized with the accuracy that can be obtained byDigits().

This is only true for symbols that have a minimum price step of 10^N, where N is an integer and not positive. If the minimum price step has a different value, then normalizing the price levels before OrderSend is a meaningless operation, which in most cases will result in the return of false OrderSend.


It's a good idea to correct outdated representations in the help.

NormalizeDouble is completely discredited. Not only is the implementation retarded, it's also meaningless on multiple exchange symbols (e.g. RTS, MIX, etc.).

As for the alternative implementation presented, it is as accurate as the original for both positive and negative. And it does rounding in the same way. Only it works 4 times faster.

 
fxsaber:

This is only true for characters that have a minimum price step of 10^N, where N is an integer and not positive. If the minimum price step has a different value, then normalizing the price levels before OrderSend is a meaningless operation, which in most cases will cause false OrderSend to be returned.

Why should it?