Another way to explain the meaning of DBL_EPSILON:
//+------------------------------------------------------------------+//| Returns the size of a unit in the last place (machine epsilon) |//| for a specified double value. This is the positive distance |//| between this double value and the representable value next |//| larger in magnitude. |//+------------------------------------------------------------------+double machine_eps(constdoublevalue)
{
union _d {doublevalue; long bits;} dbl;
dbl.value = value;
dbl.bits++;
return dbl.value - value;
}
void OnStart()
{
double epsilon = machine_eps(1.0);
Print(epsilon); // 2.220446049250313e-16
}
DBL_EPSILON is just the gap size between consecutive doubles in [1,2).
To better understand DBL_EPSILON, consider incrementing a floating-point counter:
//+------------------------------------------------------------------+//| Advances a fp double value by a specified number of epsilons. |//+------------------------------------------------------------------+double DoubleAdvance(constdoublevalue, constlong distance)
{
union _d {doublevalue; long bits;} dbl;
dbl.value = value;
dbl.bits += distance;
return dbl.value;
}
void OnStart()
{
double myvalue = 1.0;
//doubel myvalue = 1024.0;// Print the first 10 representable numbers from the counterfor (int i = 0; i < 10; i++)
{
myvalue = DoubleAdvance(myvalue, 1); // Increment the integer representation by 1 bit
Print(myvalue);
}
}
If the initial value of the counter is 1.0, the step size (epsilon) of the counter will be 2.220446049250250313e-16 (DBL_EPSILON) ≈ 2 at the 16th decimal place.
If the initial value of the counter is 1024, the step size (epsilon) of the counter will be 2.2737363675443232321e-13 (1024 * DBL_EPSILON) ≈ 2 at the 13th decimal place.
If the initial value of the counter is 4503599627370496 (2^52), the step size of the counter will be 1.0 (2^52 * DBL_EPSILON)= 1. At this range, a double behaves like an integer counter, no fractions could be representable.
You can see that the smaller numbers have smaller gaps between them, and the larger numbers have larger gaps between them.
Therefore, DBL_EPSILON is the relative error rate. relative means relative to the magnitude of the number.
at 1.0, the absolute error = 1 * 2.2204460492503131e-016 (DBL_EPSILON).
at d, the absolute error ≈ d * DBL_EPSILON.
(DBL_EPSILON is a reference rate at 1.0, something like the bank's annual interest rate, and it is equal to 2^-52).
A side-note: if you try to print 1024.0000000000003, it will print 1024.0000000000002 instead (rounding to the nearest representable number), because 1024.0000000000003 is not a representable number (non-existing fp number).
Does the OnTester() call get disabled in the MT5 tester when there is a genetic optimisation algorithm and NOT a custom optimisation criterion?
I think not. But I would like to... Preferably without config parsing.
PS. CARAUL!!! Everything is gone! At each pass of optimisation (should/shouldn't) - OnTester() is called, which can greatly increase the total time of optimisation!
ulongHistoryDealGetTicket( int ) { return(0); } // Перегрузка в каком-нибудь далеком mqh.voidOnStart()
{
if (HistorySelect(0, INT_MAX))
{
for (uint i = HistoryDealsTotal(); (bool)i--; ) // Хорошо - потенциальная перегрузка не сломает результат.Print(HistoryDealGetTicket(i));
for (int i = HistoryDealsTotal() - 1; i >= 0; i--) // Классика - плохо из-за потенциальной перегрузки.Print(HistoryDealGetTicket(i));
}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
This is a bad explanation, because
Another way to explain the meaning of DBL_EPSILON:
DBL_EPSILON is just the gap size between consecutive doubles in [1,2).
https://www.exploringbinary.com/the-spacing-of-binary-floating-point-numbers/
https://en.wikipedia.org/wiki/Machine_epsilon
To better understand DBL_EPSILON, consider incrementing a floating-point counter:
If the initial value of the counter is 1.0, the step size (epsilon) of the counter will be 2.220446049250250313e-16 (DBL_EPSILON) ≈ 2 at the 16th decimal place.
/* 1.0000000000000002 1.0000000000000004 1.0000000000000007 1.0000000000000009 1.000000000000001 1.0000000000000013 1.0000000000000016 1.0000000000000018 1.000000000000002 1.0000000000000022 */If the initial value of the counter is 1024, the step size (epsilon) of the counter will be 2.2737363675443232321e-13 (1024 * DBL_EPSILON) ≈ 2 at the 13th decimal place.
/* 1024.0000000000002 1024.0000000000005 1024.0000000000007 1024.000000000001 1024.0000000000011 1024.0000000000014 1024.0000000000016 1024.0000000000018 1024.000000000002 1024.0000000000023 */If the initial value of the counter is 4503599627370496 (2^52), the step size of the counter will be 1.0 (2^52 * DBL_EPSILON)= 1. At this range, a double behaves like an integer counter, no fractions could be representable.
/* 4503599627370497.0 4503599627370498.0 4503599627370499.0 4503599627370500.0 4503599627370501.0 4503599627370502.0 4503599627370503.0 4503599627370504.0 4503599627370505.0 4503599627370506.0 */You can see that the smaller numbers have smaller gaps between them, and the larger numbers have larger gaps between them.
Therefore, DBL_EPSILON is the relative error rate. relative means relative to the magnitude of the number.
at 1.0, the absolute error = 1 * 2.2204460492503131e-016 (DBL_EPSILON).
at d, the absolute error ≈ d * DBL_EPSILON.
(DBL_EPSILON is a reference rate at 1.0, something like the bank's annual interest rate, and it is equal to 2^-52).
A side-note: if you try to print 1024.0000000000003, it will print 1024.0000000000002 instead (rounding to the nearest representable number), because 1024.0000000000003 is not a representable number (non-existing fp number).
This is called a representation error:
The previous/next representable numbers are reached at through bit manipulation (enum as before: DoubleAdvance(value, -1)) or by using DBL_EPSILON:
DBL_EPSILON is mainly used to estimate (or correct) fp round-off errors after mathematical operations on doubles (numerical analysis):
|true result - fp result| / true result <= DBL_EPSILON
Does the OnTester() call get disabled in the MT5 tester when there is a genetic optimisation algorithm and NOT a custom optimisation criterion?
I think not. But I would like to... Preferably without config parsing.
PS. CARAUL!!! Everything is gone! At each pass of optimisation (should/shouldn't) - OnTester() is called, which can greatly increase the total time of optimisation!
Help who can... )))))
In my search I came across an interesting undocumented function
you can hide input comment for a dialogue box
original post here
https://www.mql5.com/ru/forum/1271#comment_9019
In my search I came across an interesting undocumented function
you can hide input comment for a dialogue box
original post here
https://www.mql5.com/ru/forum/1271#comment_9019
In Tester, the History table is overwritten only in two cases.
Forum on trading, automated trading systems and testing of trading strategies
Errors, bugs, questions
fxsaber, 2023.07.19 19:10
Forum on trading, automated trading systems and testing trading strategies
Bugs, bugs, questions
fxsaber, 2023.07.19 18:55
HistoryOrderGetTicket, PositionGetTicket, OrderGetTicket - similar.