Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1164
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
It is necessary to think in advance how the code is executed at the level of memory, initialization and value return.
You don't have to think it through, there are manuals for these things, and there has never been a manual for memory allocation in MQL, only messages from developers, and often with a clarification that the implementation may change
Ok, the discussion boils down to who reads what programming book, I've been reading it since high school and I'm still reading it for the last 30 years.
You don't have to think it through, there are manuals for these things, and there has never been a manual for memory allocation in MQL, only messages from developers, and often with a clarification that the implementation may change
Ok, the discussion boils down to who reads what programming book, I've been reading it since high school and I'm still reading it for the last 30 years
Of course you don't have to think it through, why should you... The compiler will do it all by itself. ))
C# is not C
And look at the video on __inline.
It explains there how functions work in memory for those who don't make any difference.
Draw a picture first and specify what the 'zero bar' for an indicator with the shift parameter is for you.
Drawn. The zero bar is highlighted with a vertical line.
Drawn. The zero bar is highlighted with a vertical line.
Example code:
Result:
As you can see, it's copyable without any tinkering.
Example code:
Result:
As you can see it's copied easily, without any tambourine.
Example code. Based on an indicator. Indicator is busy allocating buffer memory.
When start_pos = 0, the value corresponding to the 0th bar of the chart is on position 5. 1.017041 It is on position 0 in your EA. Ok.
But I need to get this value at zero position.
I set start_pos = 5. I don't get the required result. The value I am looking for is again at position 5.
I set start_pos = -5. I do not get the desired result. Again the value I am looking for is at position 5.
I set start_pos = -10. And only now I get the desired result.
Example code. Based on the indicator. The indicator is busy allocating buffer memory.
When start_pos = 0, the value corresponding to the 0th bar of the chart we see on position 5. 1.017041 In your EA it is on position 0. Ok.
But I need to get this value at zero position.
I set start_pos = 5. I don't get the desired result. The value I am looking for is again at position 5.
I set start_pos = -5. I do not get the desired result. Again the value I am looking for is at position 5.
I set start_pos = -10. And only now I get the desired result.
We need to understand the difference between the work from the Expert Advisor and from the indicator. For work from indicator use example from help(iMA).
You need to understand the difference between operating from an EA and from an indicator. To work from an indicator, use the example from the help(iMA).
So you take an example from the iMA help, add
and verify that the value is different from your EA's output value by exactly ma_shift of bars.
I, on the other hand, need to get in the indicator in iMABuffer[0] the value as you have in your Expert Advisor in array_ma[0].
At least at the moment we can see that behavior of CopyBuffer for Expert Advisors and indicators is different. If you understand the difference in CopyBuffer when working with an EA and an indicator, please specify the appropriate section of the documentation to study.
I'll try to simplify the question. How do I get these MA values (starting from the red vertical line and to the left) to the buffer in the indicator? Can you write an example?
I'll try to simplify the question. How do I get these MA values (starting from the red vertical line and to the left) to the buffer in the indicator? Can you write an example?
In the screenshot, the buffer display is shifted five bars to the right. So - to get the fifth bar of the indicator buffer (index 4), and further to the left in the list, where should we get them from? From Buffer[4] and further to the left.
In theory. In practice - I haven't opened the indicator code or worked with it for a long time - almost a year... Give it a try.
In theory. In practice - I haven't opened the indicator code or worked with it for a long time - almost a year... Give it a try.
You can't lose a skill.