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

 
LOA:


Three maxima for the period, not the most recent. Or rather, not necessarily the last.

Look: you have an array with values. You need to find three maxima in this array. They don't have to be the last or first in the timeseries array. You just need to find the three maxima.

1. Let's copy your array into a temporary one (we will look for them in the temporary array):

int ArrayCopy( object &dest [], object source[], int start_dest=0, int start_source=0, int count=WHOLE_ARRAY)

Copies one array into another. The arrays must be of the same type. Arrays of type double[], int[], datetime[], color[], and bool[], can be copied as arrays of the same type.
Returns the number of copied elements.
Parameters:
dest[] - Array-receiver.
source[] - Source array.
start_dest - Start index for the destination array. By default, the start index is 0.
start_source - Start index for source array. The default start index is 0.
count - Number of elements to copy. By default, the whole array(WHOLE_ARRAY).


2. look for maximal value in temporary array:

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[] - Numeric array to search in.
count - Number of elements to search.
start - Start - Start index for search.


3. Save found index into array (e.g. MassIndexMaxValue[])

4. zero the value of found maximum in time array - just write zero there

5. Again search for the next maximum value in the temporary array (the index of the first one we have found is already stored in MassIndexMaxValue[] and the value of this maximum is zeroed)

This loop goes on until we find the required number of maximal values in the temporary array.

MassIndexMaxValue[] array will now contain indexes of the required number of maximal values in your array.
Let's reset the size of the temporary array to zero - there's no reason to clog memory

That's how it goes...

ZS... I just did a quick sketch on the spot... I may have made a mistake - I was awake when I was writing and didn't check anything, but the function has something like this content:

void FindMaxValue(double &ms[], int &ind[], int NumMaxValue) {   
   int i, IndMax;
   double tmp[];                       // создаём временный массив
   ArrayResize(ind,NumMaxValue);       // изменяем размер массива индексов максимальных значений под количество макс. значений
   ArrayResize(tmp,ArraySize(ms));     // размер временного массива = размеру вашего массива значений
   ArrayCopy(tmp, ms);                 // копируем ваш массив во временный
   for (i=0; i<NumMaxValue; i++) {     // цикл по количеству искомых максимумов
      IndMax=ArrayMaximum(tmp);        // ищем индекс максимального значения
      ind[i]=IndMax;                   // сохраняем индекс i-го максимального значения
      tmp[IndMax]=0;                   // обнуляем i-е найденное максимальное значение во временном массиве
      }
   ArrayResize(tmp,0);                 // обнуляем размер временного массива
   return;   
}

When it's called:

FindMaxValue(Ваш_Массив_Значений, MassIndexMaxValue, 3);

... The previously defined array int MassIndexMaxValue[] must contain the indices of the three maximal values found in your_Array_Value[];

 

I can't figure out how the percentage of profit per trade and percentage of loss per trade are calculated. Can you tell me?

http://www.assessor.ru/forum/index.php?t=822

 
artmedia70:

Look: you have an array with values. You need to find three maxima in this array. They don't have to be the last or first in the timeseries array. You just need to find the three maxima.


Artem, thank you very much!

I'm glad that my idea with zeroing out the maximum value of the array was correct, and you've described everything in detail, with copying into another array, now I will deal with the minutiae

And following Vladimir's advice I will start with the algorithm of the program, I will process your information and I am sure everything will work out - good teachers.

SPECIAL THANKS FOR THE ARTICLE https://www.mql5.com/ru/articles/1357

 

Good afternoon!

Can you please tell me how to get signals from a custom indicator into an Expert Advisor?

I used iCustom, but owls still don't receive the signal

double Signal_I=iCustom(NULL,0,"FL",0,0);
 
skyjet:

Good afternoon!

Can you please tell me how to get signals from a custom indicator into an Expert Advisor?

I used iCustom, but owls still don't get the signal


Perhaps the iCustom indicator code doesn't lend itself to it... there is too little information in your question to answer.
 
skyjet:

Good afternoon!

Can you please tell me how to get signals from a custom indicator into an Expert Advisor?

I used iCustom, but owls still don't receive the signal


Is it the same with other indicators? If yes, you incorrectly use the iCustom() function. If no, try to check the code of the indicator - it may be that your indicator doesn't use any indicator buffer at all - it works with the construction of graphical objects.
 

Hello, there is a function:

bool Trade()
{
  if(!IsConnected())
  {
     Print("Связь отсутствует.");
     return(false);
  }

  if(!IsExpertEnabled())
  {
     Print("Торговля экспертами выключена.");
     return(false);
  }
  
  if(DayOfWeek()==0 || DayOfWeek()==6)
  {
     Print("В выходные не торгуем.");
     return(false);
  }
  
  if(!IsTradeAllowed())
  {
     Print("Торговля запрещена? WTF???.");
     return(false);
  }
  return(true);
}

But it doesn't work for some reason. It is called in the EA right at the beginning after int start() as follows:

  if(!Trade())
  {
    Sleep(5000);
    return;
  }

The Expert Advisor is loaded successfully in the Log and Experts tabs, and nothing else appears. Although it should say, "We do not trade on weekends." Because 26.11.2011 is Saturday.

Where is the error and what am I doing wrong?

 
Roman.:

Perhaps the iCustom indicator code does not lend itself to... There is too little information in your question to answer.
The indicator draws support and resistance lines, which it does during visualisation. The indicator itself gives a signal LT_1 == 1 or -1 when crossed.
if((Close[i] > BuyLevel) 
         {
    
          LT_1=1;
               
         }                                 
       if((Close[i] < CloseLevel)
         {
           
           LT_1=-1;
               
         }
 
ivan2k2:

Hello, there is a function:

But it doesn't work for some reason. It is called in the EA right at the beginning after int start() as follows:

The Expert Advisor is loaded successfully in the Log and Experts tabs, and nothing else appears. Although it should say, "We do not trade on weekends." Because 26.11.2011 is Saturday.

Where is the error and what am I doing wrong?


Today is Saturday - a day off. You start Expert Advisor, initialization occurs, but since it is day off and there is no tick, the start function is not started (i.e. Trade() is not called.). To check if it works correctly, you need to stick the call of this function in the initialization block, or test it in the tester.
 
skyjet:
The indicator draws support and resistance lines, which it does during visualisation. The indicator itself gives a signal LT_1 == 1 or -1 when crossed.

Then do not bother at all - just move the code of the indicator to the Expert Advisor as it is to fulfill the trading criteria and that's all - then in the board, according to these transferred trading conditions with this indicator, you open positions through the Expert Advisor and that's it ...
Reason: