Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 820

 
79014393347az:
hello! please help how to write in RSI alert, push notifications tried it myself it does not work gives an error
I want to know what you did and what error you got.
Code.
 

What is the reason for not playing audio if PlaySound() returns true?


v1 = (Up[i] != EMPTY_VALUE ? Up[i] : Down[i]);
v2 = (Down[i+1] != EMPTY_VALUE ? Down[i+1] : Up[i+1]);
         
if((v2 >= level || v2 <= level * (-1)) && a2 < Time[i])
  {
   a2 = Time[i];
   if(arrows == e1 && v2 >= level) {ArrowCreate(false,Time[i+1],High[i+1]);} else if(arrows == e1) {ArrowCreate(true,Time[i+1],Low[i+1]);};
   if(prev_calculated != 0)
     {
      if(sounds == e1 && v2 >= level) {al = PlaySound("SELL NOW"); Alert(al);} else if(sounds == e1) {al = PlaySound("BUY NOW"); Alert(al);};
      if(alerts == e1 && v2 >= level) {Alert(_Symbol+TF(Period())+" SELL NOW");} else if(alerts == e1) {Alert(_Symbol+TF(Period())+" BUY NOW");};
      if(push == e1 && v2 >= level) {SendNotification(_Symbol+TF(Period())+" SELL NOW");} else if(push == e1) {SendNotification(_Symbol+TF(Period())+" BUY NOW");};
     };
  };
 
Alexandr Sokolov:

What is the reason for audio not playing if PlaySound() returns true?


  1. Are the names of the audio files correct?
  2. After PlaySound() you have Alert() immediately - both functions play audio. Remove Alert()
 
Artyom Trishkin:
  1. Are the names of the sound files correct?
  2. After PlaySound() you have Alert() immediately - both functions play sound. Remove Alert()

The names are correct. The reason turned out to be the alerts. MANY THANKS! It's been a few days since I could figure out what the reason is.

 
Is it possible to make a setting in the compiler program settings to change the colour of the user functions from the default black to a different colour, we are talking about highlighting the user functions?
 
How does ArrayMaximum() function, which is attached by default in the compiler, work? So, the essence of the question is this: this function finds the maximum value in the array, I think that if the array contains values in a chaotic order, in order to find the maximum or minimum value, these values should be first sorted and only then you can choose the maximum value, which will be at the end or at the beginning of the list of the sorted array, how this function finds the maximum value if they are written in a chaotic order?
 
Seric29:
How does ArrayMaximum() function work which is included into the compiler by default? So, the crux of the question is this: this function finds the maximum value in the array, I think that if the array contains values in a chaotic order, in order to find the maximum or minimum value, these values should first be sorted and only then can you choose the maximum value, which will be at the end or at the beginning of the list of the sorted array, how will this function find the maximum value if they are written in a chaotic order?

There is no need to sort anything. The ArrayMaximum() function finds the maximum value in the unsorted array and returns the index of the valuefound .

 
Alexey Viktorov:

There is no need to sort anything. The ArrayMaximum() function finds the maximum value in an unsorted array and returns the index of the valuefound .

But it still needs to be lined up in some chain to compare it with one or another value, if there are 5 values and they are written in a chaotic order, the only way to find the maximum or minimum is to compare them all, in any case you need a buffer to store values.

 
Seric29:

But it still needs to be lined up in a chain to be compared to this or that value, if there are 5 values and they are written in a chaotic order, the only way to find the maximum or minimum is to compare them all, in any case you need a buffer to store the values.

Why try to figure out how it works internally? Well, if you want to write your own function, it's probably more convenient to sort and take the value of one of the outermost indexes. But it will hardly work faster than the built-in function. Plus, the built-in function allows you to search for a value within the designated index limits. So, simple sorting will not work. So, we will have to copy part of the array into an intermediate array and sort it already and take the required value from it, but array copying is not a very "cheap" function.

 
Good afternoon . Could you give me a hint? How would the code for the condition be: If the account balance has increased or decreased, then execute the function
Reason: