General rules and best pratices of the Forum. - General - MQL5 programming forum
When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Hi. I have been having an issue with a couple indicators I am working on. The second indicator is to read a buffer from the first indicator.
The first indicator has a buffer created to hold the data.
The second indicator creates an array to receive a copy of the buffer from the first indicator.
I have simplifed the code to the bare minimum, and the problem still exists and can be reproduced.
The second indicator gets a series of zeros on most timeframes, and a bunch of random data on other timelines. But, it is being sent this data, 123.123, in each
I gutted the two indicators, and made a very simple version of the attempt to have one indicator read a buffer from another custom indicator.
Here is the full code of each indicator.
Main Indicator:
Second Indicator, which attempts to read a buffer from the first indicator
On some timeframes, the copied buffer is populated with all zeros. On other timeframes, the copied buffer is full of random data.
I must be overlooking something quite simple here. But, in reviewing good code that I know works, and comparing to this code, I cannot find the differences.
You are assigning values to first elements of the buffer. Copy buffer will retrieve values from the last elements of the buffer - see how it does it : https://www.mql5.com/en/docs/series/copybuffer . So, you are retrieving values from last elements of the buffer (which are not assigned any values by you if the chart has more than 27 bars on chart)
Assign values to the last 14 elements of the buffer and it should work
- www.mql5.com
You are assigning values to first elements of the buffer. Copy buffer will retrieve values from the last elements of the buffer - see how it does it : https://www.mql5.com/en/docs/series/copybuffer . So, you are retrieving values from last elements of the buffer (which are not assigned any values by you if the chart has more than 27 bars on chart)
Assign values to the last 14 elements of the buffer and it should work
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi. I have been having an issue with a couple indicators I am working on. The second indicator is to read a buffer from the first indicator.
The first indicator has a buffer created to hold the data.
The second indicator creates an array to receive a copy of the buffer from the first indicator.
I have simplifed the code to the bare minimum, and the problem still exists and can be reproduced.
The second indicator gets a series of zeros on most timeframes, and a bunch of random data on other timelines. But, it is being sent this data, 123.123, in each
I gutted the two indicators, and made a very simple version of the attempt to have one indicator read a buffer from another custom indicator.
Here is the full code of each indicator.
Main Indicator:
Second Indicator, which attempts to read a buffer from the first indicator
On some timeframes, the copied buffer is populated with all zeros. On other timeframes, the copied buffer is full of random data.
I must be overlooking something quite simple here. But, in reviewing good code that I know works, and comparing to this code, I cannot find the differences.