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
Calculatethe median price on a given interval with a given number of approximations.
Hello There is an array of values.
The task is to write a function.
Input parameters:
- the array contains numbers of required elements to calculate the median - bufInBar[]
- array size -bufInBar[]- count
- number of median approximations - fokus
That is, there is a class
bufInBar[i] - используется для загрузки нужного элемента при расчете медианы BP[bufInBar[i]].CenaPerioda; - по этому значению рассчитывается медиана BP[bufInBar[i]].Period;
On output :
Filled in ascending order e.g. from 0 to 10.
That is, iffokus=10 in the condition, then at the interval i<count the ten values
will be 1 to 10.
For example
It is not clear what fokus is
In theory, the median is the value of the element in the middle of an ordered array. What is it in your case?
Example:
Array of 30 MA price values, look for the middle of the ordered array.
We get 15(L0) value in the middle of the array, then we get two arrays from L0 down and L0 up and find the middle of these arrays and so on until we get thefokus number(seven values for example)
--------------|-------------- -------|--------------|------ ---|-------|------|-------|-- fokus=7 | - значение цены
Example:
Array of 30 MA price values, look for the middle of the ordered array.
We get 15(L0) as the value in the middle of the array, then we get two arrays from L0 downwards and L0 upwards and find the middle of these arrays and so on until we get thefokus number(seven values for example)
And if there is an even number of array elements, which element will be the median, or should it be calculated as the average of two or something else?
Example:
Am I correct in assuming that we need to find seven percentiles: 12.5, 25, 37.5, 50, 62.5, 75, 87.5?
If so, divide the number of elements in the ordered array by 8 (7+1), and multiply by the number of percentile you want. We get the following element indices: 3, 7, 11, 15, 18, 22, 26.
Right, or am I going the wrong way? If so, the most important thing here is to create a parsimonious mechanism for maintaining an ordered array.
And if the array has an even number of elements, which element is the median, or should it be calculated as the average of two or something?
I think it's easier to take an even integer value.
If there are 15 elements, then the median is 8.
Do I understand correctly that we need to find seven percentiles: 12.5, 25, 37.5, 50, 62.5, 75, 87.5?
If so, divide the number of elements in the ordered array by 8 (7+1), and multiply by the number of the required percentile. We get the following element indices: 3, 7, 11, 15, 18, 22, 26.
Right, or am I going the wrong way? If so, the most important thing here is to create a parsimonious mechanism for maintaining an ordered array.
From the array of MA values you need to find the median of the whole array, then the medians of the arrays obtained above/below the first median, etc.
It seems right then, the median of the first part of the array is a quarter of the total array, and it is 25 percentile. And the median of the second part is 75 percentile.
This:
equals this: