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

 
double func(double x1=0, double x2=0, ну и далее сколько надо аналогично, double x20=0)
{
   double s=0; int k=0;
   if(x1 != 0) { s+=x1; k++; }
   if(x2 != 0) { s+=x2; k++; }
ну и далее сколько надо аналогично
   if(x20 != 0) { s+=x20; k++; }
   if(!k)return 0;

   double rez=s/k;
   Alert("Количество = ", k, "   Результат = ", rez);
   return rez;
}
 
STARIJ:
In this case, the average of all values transmitted cannot be calculated
 
Artyom Trishkin:

If the set and the number of numbers are not known in advance, there's not enough functions for every new set.

I see there's been a lot of misunderstanding again.

Forum on trading, automated trading systems & strategy testing

Any questions newbies have on MQL4, help and discussion on algorithms and codes

RomanRott, 2018.01.05 11:56


I need to pass several parameters to a function, but in different situations I need to pass a different number, known in advance
and then process these parameters in the function

In C, for example, it is implemented like this

int func(int a, int b, ...)
And we are competing with members of the telepath club as usual...
 
Alexey Viktorov:

There is a lot of confusion again, as I see it.

And as always we are competing with members of the telepathic club...
Well, to be honest, I still don't understand the task at hand. A lot of conventions are abstract, which you would not guess on your own.
If the numbers are known in advance, that's one thing. No one knows how many there are, and that determines the approach to the solution.
 
Alexey Viktorov:

It seems to me that it's all about the misunderstandings again.

And we're competing with members of the telepathic club as usual...

I personally will finish my coffee, try to guess on coffee grounds, and the code (or at least a piece of it) as such we seem not to see, so that it was clearer to dance with =)

 

Something's come up...

void OnTick()
  {
     int num = MathRand()%10+1;
     double bars[];
     if( CopyOpen( Symbol(), 0, 0, num, bars ) == num )
          func((int)SymbolInfoInteger(Symbol(), SYMBOL_DIGITS), bars);
  }

int func(int digit, double &array[])
  {
     int num = 0;
     for(int i=0; i<ArraySize(array); i++)
     {
          /* что-то делаем */
     }
     return(num);
  }

Although you were offered this option a long time ago, maybe visibility will help.

 

Good day to all. Could you please tell me what may be the problem.

I'm testing an Expert Advisor in the MT4 tester, downloaded from the Alpari website. Yesterday everything was OK, but today MetaEditor suddenly stops compiling code (does not start compilation process).

After clicking on the compile button, nothing happens. The button stays in the depressed state. I try to close the editor...the cursor turns into a clock and the editor says NO RESPONSE, but the editor does not close. It won't close even via Task Manager. Rebooting the computer - everything is exactly the same .

I have installed another terminal from the Alpari website and opened MetaEditor. Tried to compile built-in EA. It is the same .... It does not compile with or without error. Editor freezes.

I'm using XP OS.

Thank you for your help.

 

XP, or lovingly Hrusha, is a thing of the past. Need new investment in new computer, new OS, new thinking

 
STARIJ:

XP, or lovingly Hrusha, is a thing of the past. Need new investment in new computer, new OS, new thinking

But why yesterday it compiled fine. Today it stopped. I haven't updated the terminal. I didn't even have a connection to the server and I don't.
 

Greetings. Can you please tell me howto create a graphical object (like Fibonacci levels built into mt4 terminal) built from a group of graphical objects (like lines, circles, etc.)