total - the amount of values in the array to be used, 0 means all of them.
ma_period - the standard deviation indicator is calculated on the difference between a moving average and a price. ma_period is the period to be used in the moving average.
total - the amount of values in the array to be used, 0 means all of them.
ma_period - the standard deviation indicator is calculated on the difference between a moving average and a price. ma_period is the period to be used in the moving average.
Thanks SDC!
But, what is the moving average in the function? If I don't want to use, what I do?
If I want to do a "for" decreasing, is it possible? Can you explain?
if you dont want it to average you could try setting it to 1
a for decreasing is the same as a for increasing except in reverse.
for(i = 100; i > 0; i--)
Do you even understand what a standard deviation is? It is a measure of how far the values are on average from the mean.
What value of the mean are you going to use? iSTD and onArray use a moving average. If you want to specify your own mean you have to calculate the SD yourself.
Do you even understand what a standard deviation is? It is a measure of how far the values are on average from the mean.
What value of the mean are you going to use? iSTD and onArray use a moving average. If you want to specify your own mean you have to calculate the SD yourself.
Hi William, I understand what the code does, so I made the code below, what do you think? Will it work?
int lengthList = ArraySize(list); for (int index = 0; index < lengthList; index++) { for (int length = lengthList; length > index + 2; length--) double stdDev = iStdDevOnArray(list,0,length,0,MODE_SMA,index); }
- I think two loops to calculate one value is moronic.
- It does what is coded. The real question is, does is do what you think you want it to do.
- I think two loops to calculate one value is moronic.
- It does what is coded. The real question is, does is do what you think you want it to do.
I'm sorry, but you don't understood! Not an idiot, I want to calculate the values above the main diagonal!
Two loops to calculate one value is moronic | int lengthList = ArraySize(list); for (int index = 0; index < lengthList; index++) { for (int length = lengthList; length > index + 2; length--) double stdDev = iStdDevOnArray(list,0,length,0,MODE_SMA,index); } |
Same result. | int lengthList = ArraySize(list); int index = lengthList - 1; int length = lengthList; double stdDev = iStdDevOnArray(list,0,length,0,MODE_SMA,index); |
You calculate the values and throw them all away except for the last
Two loops to calculate one value is moronic | |
Same result. |
William, I understood what you sad, so I calculated the standard deviation manually, the code is below, it's correct?
double average = 0; double deviation = 0; double sum = 0; int lengthList = ArraySize(list); int position = 0; for (int index = 0; index < lengthList; index++) { for (int length = lengthList; length > index + 2; length--) // Initializes each iteration average = 0; deviation = 0; sum = 0; for (int k = index; k < length; k++) { average += list[k]; } average = average / length; for (k = index; k < length; k++) { deviation = listaFractals[k] - average; sum += MathPow(deviation,2); } // Variance, the sum of squared deviations divided by (period - 1), because is sample deviation variancie = sum/ (length - 1); // Calculates the Standard Deviation double stdDev = MathSqrt(variancie); // Normalizes the standard deviation for the number of digits in the currency pair stdDev = NormalizeDouble(stdDev,MarketInfo(Symbol(),MODE_DIGITS)); // Checks how many decimal digits of the pair has and uses the right condition for check deviation if ((MarketInfo(Symbol(),MODE_DIGITS) == 2 || MarketInfo(Symbol(),MODE_DIGITS) == 3) && (stdDev < 0.3)) { // Check the lenght of vector and resize legnthVector = ArraySize(entryList) + 1; ArrayResize(entryList,legnthVector); /** ------------------------------------- Main Code ------------------------------------- * If the point was found, it continues to iterate from the variable size to try to find another point and so subsequently. * Example: if he thought the 1-4, he continues to iteration 5 onwards. **/ entryPoints[position] = average; index = length + 1; position++; // Increment 1 to the index of the list of entry points break; } if ((MarketInfo(Symbol(),MODE_DIGITS) == 4 || MarketInfo(Symbol(),MODE_DIGITS) == 5) && (stdDev < 0.002)) { // Check the lenght of vector and resize legnthVector = ArraySize(entryList) + 1; ArrayResize(entryList,legnthVector); /** ------------------------------------- Main Code ------------------------------------- * If the point is found, it continues to iteration of "for" size that was found forward. * Example: if he thought the 1-4, he continues to iteration 5 onwards. **/ entryPoints[position] = average; index = length + 1; position++; // Increment 1 to the index of the list of entry points break; } } }
I'm trying to find the points above the diagonal, as in the table below:
1 | 2 | 3 | 4 | 5 |
1 | 2 | 3 | 4 | |
1 | 2 | 3 | ||
1 | 2 | |||
It will calculate the standard deviation in the first "for" that starts up the index list length and the other "is" decreasing from the length of the list to the index - 1, following the example below:
iStdDev(1-5); iStdDev(1-4); iStdDev(1-3); iStdDev(1-2);
If the item was found, it continues to iterate from the variable size to try to find another point and so subsequently.
Example: if he thought the 1-4, he continues to iteration 5 onwards.
I wonder if the above code is right, because I calculated manually in a period and found 4 or 5 points, I can not remember for sure, however the EA finds no point.
William, I understood what you sad, so I calculated the standard deviation manually, the code is below, it's correct?
I'm trying to find the points above the diagonal, as in the table below:
int lengthList = ArraySize(list); for (int index = 0; index < lengthList; index++) { for (int length = lengthList; length > index + 2; length--) : average += list[k]; : deviation = listaFractals[k] - average;
You calculate the mean from list. How can use calculate stddev from some other array? What was wrong with just using std on array?- I have no idea what you mean "above the diagonal" list is a one dimensional array. There is no diagonal. If what you mean is std of elements 1-2 and 1-3 ..
int lengthList = ArraySize(list); double stdDev[]; ArrayResize(stdDev, lengthList); for(int length = LengthList; length > 0; length--){ stdDev[length-1] = iStdDevOnArray(list, lengthList,length,0,MODE_SMA,0);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, can someone please explain what each of these options do exactly?
double iStdDevOnArray( double array[], int total, int ma_period, int ma_shift, int ma_method, int shift)
- array[] - Array with data. OK, simple.
- total - The number of items to be counted. What numbers exactaly?
- ma_period - MA period. Why this?
- ma_shift - MA shift.
- ma_method - MA method. It can be any of Moving Average method enumeration value.
- shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).
I want to do this, a vector scan the index as an index tail off the other, see below code:
I'm sorry for my English.