Questions from Beginners MQL5 MT5 MetaTrader 5 - page 534
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Vladimir, thanks for the answer to the first question, I missed these features.
I put one and the same indicator in MT4 and in MT5 (of course, the code is adapted to each platform).
Up to zero bar their values are the same, so apparently from one end ... :)
And when disabling the calculation on the current bar in MT4 nothing is drawn under the current bar, in MT5 - wrong values.
Forum on trading, automated trading systems and strategy testing
Questions from Beginners
Karputov Vladimir, 2016.03.08 15:13
... For debugging set check - which value is contained in time series array time[i] - so you understand at what end you start the calculation of bars and where you have a "zero" bar.
And how to put such a check ?
In MetaEditore add a breakpoint and start debugging. When the breakpoint is stopped, add time[0] to the observation:
In MetaEditore add a breakpoint and start debugging. When the breakpoint is stopped, add time[0] to the observation:
MT4 2016.03.08 18:37:04.710 mvt_Vlt EURUSD,H1: time[0] = 2016.03.08 17:00:00 time[rates_total-1] = 1971.01.04 00:00:00
MT5 2016.03.08 18:36:23.565 mvt_Vlt (EURUSD,H1) time[0] = 2010.01.04 00:00:00 time[rates_total-1] = 2016.03.08 17:00:00
Inserted in the MT5 codeArraySetAsSeries(time,true);
Now output:
MT5 2016.03.08 18:45:05.402 mvt_Vlt (EURUSD,H1) time[0] = 2016.03.08 17:00:00 time[rates_total-1] = 2010.01.04 00:00:00
And do price arrays as well ?
I already put the output in the code
MT4 2016.03.08 18:37:04.710 mvt_Vlt EURUSD,H1: time[0] = 2016.03.08 17:00:00 time[rates_total-1] = 1971.01.04 00:00
What do I do now ?
In both versions of the indicator addArraySetAsSeries- for those arrays that you use for your calculations: high[], low[] and temporarily for the time[] array - it will help you to understand where the "zero" bar is. Thus, the "zero" bar in both versions will be on the same side of the chart (right or left - depending on what you set in ArraySetAsSeries), and you will get the same calculation part of the indicator.
Added: while I was typing, you have fumbled the right way :)
Added: while I was typing, you found the right way :)
I pasted it into MT5 code:
It's coming out:
It onlyoutputs ExtCalcVlBuffer, but the average and deviation don't count...
And it still outputs on the current bar, although it shouldn't.
...
It still displays on the current bar, even though it shouldn't.
Why shouldn't it?
I turned it off i<rates_total-1
WHY?!
You don't need to use the current value, it will only load the processor in vain and you simply don't need this value.
You need to specify that right away :) .
The situation is as follows: if there is a bar in the chart, it corresponds to a cell in the indicator buffer. As long as you do not write something in this cell, this cell will store rubbish.