Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1900
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
In Vitali's example, you can use this idea. But there is no way to avoid the loop (which is critical for it). In any case, we have to transfer the data from the ring buffer to the indicator buffer using the loop or the ArrayCopy function. And what will change?
What a brilliant idea! Who came up with it and what is its practical application? I doubt it's used exclusively for sliding window charts...
Who came up with it - no end in sight, I think it's been reinvented many times, the idea is quite obvious.
I, for example, use it to calculate the moving average of data which is not stored in history, but only has an instantaneous value.
This has been used in data transmission since time immemorial.
In Vitali's example, you can use this idea. But there is no way to avoid the loop (which is critical for it). In any case, we have to transfer the data from the ring buffer to the indicator buffer using the loop or the ArrayCopy function. And what would be different?
That a new value can be inserted and immediately copied from the desired place. The copy cycle remains, but there is no shift cycle.
Checked it out, yes it's a good solution - I'm keeping it.
But I would still like to check howArrayCopy works.
With ArrayCopy, you can only transfer data from another array. But you cannot shift them. You can use a ring buffer and shift data from it... But how can you do it withArrayCopy if it has a circular motion... I don't understand. And, in principle, it doesn't need to be understood. The usual displacement using a loop is not so critical in terms of speed. At least, I don't know any faster. What can be faster, only assembler? Anyway, leave it as it is. It will work.
That a new value can be inserted and copied immediately from the correct place. The copy cycle remains, but there is no shift cycle.
Let's give an example, it would be in the
The code for upgrading is
With ArrayCopy, you can only transfer data from another array. But it is not possible to shift them. You can use a circular buffer and transfer data from it... But how to do it withArrayCopy if it has a circular motion... I don't understand. And, in principle, it doesn't need to be understood. The usual displacement using a loop is not so critical in terms of speed. At least, I don't know any faster. What could be faster, assembler? Anyway, leave it as it is. It'll work.
Right now the code works, but the speed is questionable because of the loop.
What's it going to be?
I want to test some kitchens for arbitrage capability, the indicator will draw the difference of values, runs on a timer once every 100ms. Code execution delays are critical for this situation.
This has been used in data transmission since time immemorial.
Convenient. You can't disagree with that. But as I said before, you should always consider how much data you can roll back.
Let's have an example, it'll be on topic
There isa code to upgrade
It won't work in this code because the indicator buffer lives independently of us and we don't organise a ring buffer in it - there's no way to explain this MT.
With ArrayCopy, you can only transfer data from another array. But you cannot shift them.
Who told you this nonsense?
Read carefully how it is done.
Forum on trading, automated trading systems and strategy testing
Any questions from newbies on MQL4 and MQL5, any help and discussion on algorithms and codes
Alexey Viktorov, 2022.02.13 18:21
In this code, you need to specify one array
Which index to write from and which one to copy depends on the array offset direction. So, if index 0 should always contain fresh, new data, copy from 0 and write from 1. Thus, values in index 0 and 1 will be identical, and afterwards a fresh value will be copied to 0.
And I doubt very much that ArrayCopy() has the same loop inside as the user one. So, having some array with a certain size, it is shifted by 1 on every tick and then copied into the indicator buffer that is displayed as a line...
It won't work in this code because the indicator buffer lives independently of us and we don't organize a ring buffer in it - there's no way to explain this MT.
I see.
Well, it works - let it work so far, no result yet, we must wait for our "friends" from the Pindos until the market opens, and it is not soon.
I will see what I can arbitrage.