Questions from Beginners MQL5 MT5 MetaTrader 5 - page 573
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
I'll see what I can figure out. Thank you. (chuckles)
You're welcome. It just saves all the highs into an array, and then prints all the data saved in the array into the log in a loop.
This script doesn't necessarily do exactly what you need it to do. It simply shows how the data is stored in the array.
Not at all. It simply saves all the highs into an array, and then prints out all the data saved in the array in a loop in the logbook.
This script doesn't necessarily do exactly what you need. It just shows the principle of saving data in an array.
That's exactly what I was looking for. I needed it to somehow save the data to an array for the period I choose. That's the part I understood from you.
Now my question is, HOW can I access and compare the recorded data in the array?
Here it turns out to iterate, write the array step by step. This is good. But now we need to compare the elements with each other.
Is it necessary to declare a new iteration count and then retrieve the data and compare them somehow? But this again has to write the results somewhere and ... everything repeats in the end.
Roughly, if comparison period is 5-7 candlesticks, then the 1st one should be compared to other 6, then the 2nd one and so on.... And if two or more of them have equal High, then firstly, you should calculate this High, and secondly, you should find the candlestick with the lowest Low. I.e. the function of calling concrete candlesticks in the end to fetch all their parameters.
But is it possible to do it?
that's exactly what I was looking for. I needed it to somehow store the data in an array for the period I was selecting. I understood that part.
Now my question is, HOW can I access and compare the recorded data in the array?
Here it turns out to iterate, write the array step by step. This is good. But now we need to compare the elements with each other.
Is it necessary to declare a new iteration count and then retrieve the data and compare them somehow? But this again has to write the results somewhere and ... everything repeats in the end.
Roughly, if comparison period is 5-7 candlesticks, then the 1st one should be compared to other 6, then the 2nd one and so on.... And if two or more of them have equal High, then firstly, you should calculate this High, and secondly, you should find the candlestick with the lowest Low. I.e. the function of calling concrete candlesticks in the end to fetch all their parameters.
But is it possible to do it?
Here we are just interrogating the saved array and displaying all the saved data in the log:
Let's be more specific about the task:
We need to find ... what exactly in the saved array?
This is where the saved array is interrogated, and all saved data is logged:
Let's be specific about the task:
We need to find in the saved array ... what exactly?
I need, to record an array of data for all closed candles (i.e. the current one is not counted) - High, Low, Open, Close candles (4 parameters) for the period which is specified in the settings. - it is.
Next, I need to compare the parameters. Suppose the search period is equal to 10 candlesticks. Here we need to check all High for the period of 10 candlesticks. If there are two or more matches, we should return:
1. Flag - "There is a match".
1. The High value where the candlesticks have the same value.
2. Numbers of these candlesticks, so we can refer to them and find out Low, Close, Open parameters for them.
In general, I understand much of this how to do it.
What is not clear is how to refer to those candlesticks which form the level. Ideally, when recalculating, we could memorize the number of iteration (i) but first we have a recalculation according to which the log is written and it cannot be applied.
And in that variant, as the output log records - this is also not what is required.
I understand that I need to first take a candlestick 1 and compare it with 9 others, if there is a match, then extract the numbers of these candles and their parameters, turn on the checkbox. Then check candle 2 with the others and so on to the middle of the sample, as then will go duplicates of comparisons only from the other side.
If the number of candlesticks was fixed, I would have written it like this - roughly 5 comparison cycles. But that's the question - how to make such recalculation possible for any sample size.
I need to write an array of data for all closed candles (i.e. the current one is not counted) - High, Low, Open, Close candles (4 parameters) for the period specified in the settings. - it is.
Next, I need to compare the parameters. Suppose the search period is equal to 10 candlesticks. Here we need to check all High for the period of 10 candlesticks. If there are two or more matches, we should return:
1. Flag - "There is a match".
1. The High value where the candlesticks have the same value.
2. Numbers of these candlesticks, so we can refer to them and find out Low, Close, Open parameters for them.
In general, I understand much of this how to do it.
What is not clear is how to refer to those candlesticks which form the level. Ideally, when recalculating, we could memorize the number of iteration (i) but first we have a recalculation according to which the log is written and it cannot be applied.
And in that variant, as the output log records - this is also not what is required.
I understand that I need to first take a candlestick 1 and compare it with 9 others, if there is a match, then extract the numbers of these candles and their parameters, turn on the checkbox. Then check candle 2 with the others and so on to the middle of the sample, as then will go duplicates of comparisons only from the other side.
If the number of candlesticks was fixed, I would have written it like this - roughly 5 comparison cycles. But that's the question - how to make such a recalculation possible for any sample size.
And by the way, the exact coincidence of price values is unlikely to be frequent. We need to set some delta, and consider it a coincidence if prices do not differ more than this value.
I need to write an array of data for all closed candles (i.e. the current one is not counted) - High, Low, Open, Close candles (4 parameters) for the period specified in the settings. - it is.
Next, I need to compare the parameters. Suppose the search period is equal to 10 candlesticks. Here we need to check all High for the period of 10 candlesticks. If there are two or more matches, we should return:
1. Flag - "There is a match".
1. The High value where the candlesticks have the same value.
2. Numbers of these candlesticks, so we can refer to them and find out Low, Close, Open parameters for them.
In general, I understand much of this how to do it.
What is not clear is how to refer to those candlesticks which form the level. Ideally, when recalculating, we could memorize the number of iteration (i) but first there is a recalculation according to which the log is written and it cannot be applied.
And in that variant, as the output log records - here, too, is not what is required.
I understand that I need to first take a candlestick 1 and compare it with 9 others, if there is a match, then extract the numbers of these candles and their parameters, turn on the checkbox. Then check candle 2 with the others and so on to the middle of the sample, as then will go duplicates of comparisons only from the other side.
If the number of candlesticks was fixed, I would have written it like this - roughly 5 comparison cycles. But that's the question - how to enable such a recalculation for any sample size.
Instead of flag "coincidence" set the counter, on value high where the counter is greatest, there is a level
The high value can be rounded up, for example 1.23456 to 1.2346
and 1.23462 rounded up to 1.2346
because it is unlikely that out of 10 candlesticks, 2 will have a high of 1.23456
so dance from the level
and the number of candlesticks is fixed, you write a certain amount of data into the structure
i.e. the number of candlesticks written in the structure is the same number of iterations
I need to write an array of data for all closed candles (i.e. the current one is not counted) - High, Low, Open, Close candles (4 parameters) for the period specified in the settings. - it is.
Next, I need to compare the parameters. Suppose the search period is equal to 10 candlesticks. Here we need to check all High for the period of 10 candlesticks. If there are two or more matches, we should return:
1. Flag - "There is a match".
1. The High value where the candlesticks have the same value.
2. Numbers of these candlesticks, so we can refer to them and find out Low, Close, Open parameters for them.
In general, I understand much of this how to do it.
What is not clear is how to refer to those candlesticks which form the level. Ideally, when recalculating, we could memorize the number of iteration (i) but first we have a recalculation according to which the log is written and it cannot be applied.
And in that variant, as the output log records - here, too, is not what is required.
I understand that I need to first take a candlestick 1 and compare it with 9 others, if there is a match, then extract the numbers of these candles and their parameters, turn on the checkbox. Then check candle 2 with the others and so on to the middle of the sample, as then will go duplicates of comparisons only from the other side.
If the number of candlesticks was fixed, I would have written it like this - roughly 5 comparison cycles. But here's the question: how to make such a recalculation possible for any sample size.
It is an interesting task, but your understanding of how to solve this problem is not correct, because so far you don't have much knowledge in programming.
Look: you have some set of quotes. Your task is to choose from this set only those bars which meet certain conditions. For example, you want to get a collection of bars, whose highs coincide with each other. In fact, there can be many conditions for the selection, and they can be added to over time. Once you have a collection of bars, you can easily analyze any of their other parameters.
So, for your task, you need to write a function that would return an array of bars satisfying a certain condition (pseudocode):
I.e. there's really no problem remembering and iterating some data and indexes. You don't need the indexes of the bars themselves, but a specific collection that satisfies a given condition. Once you have it, you solve a lot of problems in one fell swoop.So, if we need a different list of matching candlesticks for each candlestick in the range, I would try to use an array of structures. I'll think about it and let you know.
Thought. I am writing out a test script:
Tried to describe all the steps.
After filling in all matches in the loop, we have an array containing all candlesticks and their matching candlesticks. After that you may look for low in it. And you can organize it right in the loop. It is more convenient to you.
Well, here's another way to do it: matches are written for each candle in the range. In the previous version, the matches were written only for one candle - i.e. no match was written for the one that matched this one.