# New MetaTrader 5 platform build 3210: Revised Sharpe Ratio calculation algorithm, new matrix methods and control over indicator minimum/maximum values

Forum on trading, automated trading systems and testing trading strategies

Custom Indicator showing ZERO level, though not defined anywhere in the code

Alain Verleyen, 2022.02.10 17:49

Almost fixed in build 3191.

It remains a bug as I warned about it. To reproduce :

1 - On a chart, without a grid, attach the provided indicator. All is displayed correctly.

2 - Enable the grid. (CTRL+G or click on button...). The Level 0 line is NOT displayed. This is a bug. Disable the grid again, the level is shown.

The problem is the grid is not in the background. If you are using a dot line level it's BEHIND the grid, that's not correct. If you set a solid line it's shown as the grid can't mask it completely. A level should have priority on a grid.

**MetaQuotes:**

The MetaTrader 5 platform update will be released on Friday, February the 11th, 2022.

The update provides the revised Sharpe Ratio calculation algorithm based on a traditional formula, new matrix methods, optimized memory consumption, and improved network system operation for better data transfer.

We have also added two new properties, INDICATOR_FIXED_MINIMUM and INDICATOR_FIXED_MAXIMUM, in the ENUM_CUSTOMIND_PROPERTY_INTEGER enumeration, which fix/unfix minimum and maximum indicator values using the IndicatorSetDouble function.

In addition, we have fixed some errors in the Math\Stat\Math.mqh mathematical library and corrected the operation of the CopyTicks and CopyTicksRange functions, which could return outdated data when crossing over midnight.

- MQL5: Added Min, Max, ArgMin, ArgMax and Sum functions for vectors and matrices. Use the functions to find the minimum and the maximum values, relevant indexes and the sum.
- MQL5: Added support for Flat methods for the matrix. With these methods, a matrix element can be addressed through one index instead of two.

Pseudocode for calculating the address of a matrix element:

For example, for 'matrix mat(3,3)', access to elements can be written as follows:

reading: 'x=mat.Flat(4)', which is equivalent to 'x=mat[1][1]'

writing: 'mat.Flat(5, 42)', equivalent to 'mat[1][2]=42'

If the function is called with an invalid matrix index, the OutOfRange critical execution error will be thrown.

- MQL5: Improved formatting of floating-point numbers in MQL5-program input parameters. When reading some real numbers, numbers with many zeros were substituted into the input parameters, for example, 0.4 was represented as 0.400000000002.

- MQL5: Fixed errors in the Math\Stat\Math.mqh math library. The MathSample function from this library has been revised to match the traditional behavior of similar math libraries when sampling with backtracking.

- MQL5: Fixed CopyTicks/CopyTicksRange error which could cause the return of outdated data when crossing over the midnight, when no ticks are provided for the financial instrument.
- MQL5: Added new INDICATOR_FIXED_MINIMUM and INDICATOR_FIXED_MAXIMUM values into the ENUM_CUSTOMIND_PROPERTY_INTEGER enumeration.

Using these properties, you can fix or unfix the minimum and maximum indicator values using the IndicatorSetInteger function. When calling IndicatorSetInteger(INDICATOR_FIXED_MINIMUM/INDICATOR_FIXED_MAXIMUM, true), the current minimum or maximum value is used.

- Tester: Revised Sharpe Ratio calculation algorithm to match the traditional formula, in which the value corresponds to a one-year interval. The previous algorithm was based on the variability of obtained PnL and it ignored equity fluctuations against open positions. Now the calculation includes equity movements, while the Sharpe ratio is interpreted in a classical way:
- Sharpe Ratio < 0 The strategy is unprofitable and is not suitable. Bad.
- 0 < Sharpe Ratio < 1.0 The risk does not pay off. Such strategies can be considered when there are no alternatives. Indefinite.

- Sharpe Ratio ≥ 1.0 If the Sharpe ration is greater than one. This can mean that the risk pays off and that the portfolio/strategy can show results. Good.

- Sharpe Ratio ≥ 3.0 A high value indicates that the probability of obtaining a loss in each particular deal is very low. Very good.

- Terminal: Optimized memory consumption by the terminal.
- Terminal: Improved platform operation with a network subsystem to enhance performance and to reduce network delays.
- Terminal: Removed the display of the zero grid level in indicators when grid rendering is disabled.

The update will be available through the Live Update system.

At around last christmas I reported a bug of the debugger, seeming not to know certain objects in certain circumstances. This wasn't adressed up to now. To me it seems no one looked into it, maybe because it looks similar to another file I sent shortly before it, showing a bug that thankfully has already been resolved. Please see the MQL5-Script file inside of the attached ZIP-file. A breakpoint needs to be set at line 78930 - almost at the bottom and try observing the variable called agpComplete[]. You won't be able to look into it. I hope the resolution of this will solve the actual remaining problem with debugging I have, but we'll see.

Thank you in advance

**Files:**

**Markus #:**

At around last christmas I reported a bug of the debugger, seeming not to know certain objects in certain circumstances. This wasn't adressed up to now. To me it seems no one looked into it, maybe because it looks similar to another file I sent shortly before it, showing a bug that thankfully has already been resolved. Please see the MQL5-Script file inside of the attached ZIP-file. A breakpoint needs to be set at line 78930 - almost at the bottom and try observing the variable called agpComplete[]. You won't be able to look into it. I hope the resolution of this will solve the actual remaining problem with debugging I have, but we'll see.

Thank you in advance

I confirm the problem, tested with beta build 3194.

Is there a specific formula ?

The 15min delayed issue reported on the forum, is now appearing on my setup too with this build.

In my case it is appearing on all my accounts, real and demo, normal and ECN accounts, USD and EUR balances. I have also checked with the broker support and have confirmed that none of the accounts are delayed.

I'm not the only one having this issue, so either it is a bug in MetaTrader build or a setup problem on multiple brokers servers.

Hi Alain. Sorry in advance if you've already answered this question many times over, however I use NormalizeDouble() alot - What is your suggested / most reliable alternative?

Ed. actually - looked it up and refactoring now for all trade and chart plotting ops - instead of using NormalizeDouble( ... , _Digits) etc. Using these functions instead;

double NormalizePrice(double p) { // Prices to open must be a multiple of ticksize double ts = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE); return( MathRound(p / ts) * ts ); } double NormalizeLots(double lots) { double minlot = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN); LotStep = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP); lots = MathRound(lots/LotStep) * LotStep; if (lots < minlot) lots = minlot; // or 0 return(lots); }

- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets

You agree to website policy and terms of use

The MetaTrader 5 platform update will be released on Friday, February the 11th, 2022.

The update provides the revised Sharpe Ratio calculation algorithm based on a traditional formula, new matrix methods, optimized memory consumption, and improved network system operation for better data transfer.

We have also added two new properties, INDICATOR_FIXED_MINIMUM and INDICATOR_FIXED_MAXIMUM, in the ENUM_CUSTOMIND_PROPERTY_INTEGER enumeration, which fix/unfix minimum and maximum indicator values using the IndicatorSetDouble function.In addition, we have fixed some errors in the Math\Stat\Math.mqh mathematical library and corrected the operation of the CopyTicks and CopyTicksRange functions, which could return outdated data when crossing over midnight.

These changes, along with other new features of the updated MetaTrader 5 platform version, are described in detail below:Pseudocode for calculating the address of a matrix element:

For example, for 'matrix mat(3,3)', access to elements can be written as follows:

reading: 'x=mat.Flat(4)', which is equivalent to 'x=mat[1][1]'writing: 'mat.Flat(5, 42)', equivalent to 'mat[1][2]=42'

If the function is called with an invalid matrix index, the OutOfRange critical execution error will be thrown.

Using these properties, you can fix or unfix the minimum and maximum indicator values using the IndicatorSetInteger function. When calling IndicatorSetInteger(INDICATOR_FIXED_MINIMUM/INDICATOR_FIXED_MAXIMUM, true), the current minimum or maximum value is used.

The update will be available through the Live Update system.