[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 354

 
There is a work by N. Staritsky. There is a film based on it called "Beyond Two Hares". I want to read this brilliant author. I can not find his text. Help me find it. and sorry if I asked in the wrong thread ;)
 

How does ArrayMaximum work?

int ArrayMaximum( double array[], int count=WHOLE_ARRAY, int start=0)

Search for the element with the maximum value. The function returns the position of the maximal element in the array.
Parameters:array[] - The numeric array to search in.
count - The number of elements to search.
start - The starting index of the search.

Example:
double num_array[15]={4,1,6,3,9,4,1,6,3,9,4,1,6,3,9};
int maxValueIdx=ArrayMaximum(num_array);
Print("Max value = ", num_array[maxValueIdx]);

so it's not clear to me... How can I write it, so that the Expert Advisor searches for, say, the 2nd array number?

int MinArray[7] = {1,2,3,4,5,6,7}

int ArrayMaximum (MinArray[7], "What about here?", 2); it's not clear to me

 
splxgf:

For example, the problem was how many times the price crossed given levels in the last two years.

1. You could take each level and look at the data for two years. Cost: number of bars multiplied by the number of levels.

2. You can create a separate array of levels. It is enough to review all the bars by checking and incrementing the required elements of the array. In this case the calculations will be faster.

I'm interested in an example similar to this one:

for(a=0;a<=100;a++){

for (b=0;b<=100;b++){

for (c=0;c<=100;c++){

for(d=0;d<=100;d++){

for(e=0;e<=100;e++){

for (f=0;f<=100;f++){

for(g=0;g<=100000;g++){

jaw_val1=iAlligator(NULL, 0, a, b, c, d, f, e, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, g);

jaw_val2=iAlligator(NULL, 0, a, b, c, d, f, e, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, g);

jaw_val3=iAlligator(NULL, 0, a, b, c, d, f, e, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, g);

if (jaw_val1>Close[g] && jaw_val2>Close[g] && jaw_val3>Close[g]) sum=sum+(High[g]-Low[g])

}}}}}}}


But then the array must be 7-dimensional?

 
CLAIN:

can you tell me how ArrayMaximum works?

int ArrayMaximum( double array[], int count=WHOLE_ARRAY, int start=0)

Search for the element with the maximal value. The function returns the position of the maximal element in the array.
Parameters:array[] - Numerical array, that is searched.
count - The number of elements to search.
start - The starting index for searching.

Example:
double num_array[15]={4,1,6,3,9,4,1,6,3,9,4,1,6,3,9};
int maxValueIdx=ArrayMaximum(num_array);
Print("Max value = ", num_array[maxValueIdx]);

so this is where I don't understand count... How do I write my Expert Advisor to search for, say, the 2nd array number?

int MinArray[7] = {1,2,3,4,5,6,7}

int ArrayMaximum (MinArray[7], "What about here?", 2); it is not clear to me

Suppose you have a DataMass[] array that contains some values. The type of values in it is double.

You need to find the largest value contained in this array, starting from the zero element of the array:

int IndexMaxValue=ArrayMaximum(DataMass, WHOLE_ARRAY, 0); // find index of element with the highest value.

double MaxValue=DataMass[IndexMaxValue]; // find the maximal value in the array by its index

The line of searching for the element with the maximum value can be written in a shorter form:

int IndexMaxValue=ArrayMaximum(DataMass); // The last two arguments of the function have default values, so they can be omitted when the function is called, because we are searching the whole array (WHOLE_ARRAY) and starting from zero cell (0), and these values are passed to the function by default.

All this can be written in one line

double MaxValue=DataMass[ArrayMaximum (DataMass)]; // find the maximum value in the array by its index.

The variable MaxValue will contain the maximum value in the array DataMass[].


If you want to search not in the whole array and not starting from the zero element, these values should be specified explicitly in the parameters passed:

int IndexMaxValue=ArrayMaximum(DataMass, WHOLE_ARRAY, 2); // find the index of the element with the largest value. The search is performed over the entire array (WHOLE_ARRAY), starting from the second cell (2)

int IndexMaxValue=ArrayMaximum(DataMass, 10, 3); // find the index of the element with the largest value. The search is performed for ten elements of the array (10), starting from the third cell (3)


I hope I explained it clearly :)

 
artmedia70:
Suppose you have a DataMass[] array that contains some values. The type of values it contains is double.

You need to find the largest value contained in this array, starting from the zero element of the array:

int IndexMaxValue=ArrayMaximum(DataMass, WHOLE_ARRAY, 0); // find the index of the element with the highest value.

double MaxValue=DataMass[IndexMaxValue]; // find the maximum value in the array by its index

The line of searching for the element with the maximum value can be written in a shorter form:

int IndexMaxValue=ArrayMaximum(DataMass); // The last two arguments of the function have default values, so they can be omitted when the function is called, because we are searching the whole array (WHOLE_ARRAY) and starting from zero cell (0), and these values are passed to the function by default.

Now we can write it all in one line

double MaxValue=DataMass[ArrayMaximum (DataMass)]; // find the maximum value in the array by its index

If you want to search not in the whole array and not starting from the zero element, you should specify these values explicitly in the parameters passed

int IndexMaxValue=ArrayMaximum(DataMass, WHOLE_ARRAY, 2); // find the index of the element with the largest value. The search is performed for the entire array (WHOLE_ARRAY), starting from the second cell

int IndexMaxValue=ArrayMaximum(DataMass, 10, 3); // find the index of the element with the largest value. The search is performed over ten elements of the array (10), starting from the third cell

I hope I explained it clearly :)



more than =) thanks, but one question still remains.... what if i have 2 identical max values, which one will it pick? the one on the left?
 
CLAIN:

more than that =) thanks, but one question still remains.... what if i have 2 identical max values, which one will it pick? the one on the left?

Check it :)

Write a short script, which will output the maximal value found in the array and its index. Initialize the array explicitly with values, two of which will be the same and will be larger than the other values.

Use the index to determine which of the two highest values it outputs to you.

 

Outputs the index of the one closest to the start of the search:

//+------------------------------------------------------------------+
//|                                                         Test.mq4 |
//|                             Copyright © 2011, Trishkin Artyom A. |
//|                                           support@goldsuccess.ru |
//|                                           Skype: artmedia70      |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Trishkin Artyom A."
#property link      "support@goldsuccess.ru"
//                   Skype: artmedia70
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
double DataMass[15]={4,1,6,3,19,4,1,6,3,19,4,1,6,3,9}; // индекс первого = 4, индекс второго = 9

int start()
  {
//----
   int IndexMaxValue=ArrayMaximum(DataMass); 
   double MaxValue=DataMass[IndexMaxValue]; // находим максимальное значение в массиве по его индексу
   Alert("Индекс максимального элемента массива = "+IndexMaxValue+", его значение = "+MaxValue);
//----
   return(0);
  }
//+------------------------------------------------------------------+

Guess which index it outputs :)

 
drknn:
There is a work by N. Staritsky. There is a film based on it called "Beyond Two Hares". I want to read this brilliant author. I can not find his text. Help me find it. and sorry if I asked in the wrong thread ;)
Vladimir, it's a play. Here's the text.
 

Good morning, I have two questions (I can't find any digestible answer anywhere):

1. the indicator draws two rows of vertical trend lines in the sub-window. How do I get the bar numbers that correspond to these lines?

2. In the same indicator I need to draw lines in future for about 24 hours ahead. But I do not know how to implement it in the best way.

I very much hope for help from forum users!)

 
Help to add a function to delete orders please!
Reason: