Need an advice

 

I need to use 5 different indicators and to summarize their result in a signal for buy/sell order. Here is a simple example of my idea. My difficulty is the connected with the hierarchy of the code in the functions. May you recommend me a way for summarizing the result? I suggest one of the ways is counting, but I am not really sure how to apply this on several functions.

void OnTick()

   {  
      double A;
      double B;
      double C;
      double D;
      double E;
      double Result;
      double signal[];
      string Order;

      //Example values
      A = 1;
      B = 1;
      C = 1;
      D = -1;
      E = -1;

      

      if(A>0) signal[0] = +1;
      else if(A<0) signal[1] = -1;
      
      if(B>0) signal[2] = +1;
      else if(B<0) signal[3] = -1;
      
      if(C>0) signal[4] = +1;
      else if(C<0) signal[5] = -1;
      
      if(D>0) signal[6] = +1;
      else if(D<0) signal[7] = -1;
      
      if(E>0) signal[8] = +1;
      else if(E<0) signal[9] = -1;

      

      //If the value > 0 => buy; If the value < 0 => sell

      Result = signal[0] + signal[1] + signal[2] + signal[3] + signal[4] +

      signal[5] + signal[6] + signal[7] + signal[8] + signal[9];
      
      if(Result>0) Order="Buy";
      else if (Result<0) Order="Sell";
      
      Comment ("Order: ",Order);
   }
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2.     double signal[];
        ⋮
          if(A>0) signal[0] = +1; 
    Signal has no size — you can't assign to it.

  3. Signal has no purpose — just create the result.
    result = (A>0 ? +1 : -1)
           + (B>0 ? +1 : -1)
           ⋮
           + (E>0 ? +1 : -1);

 
William Roeder:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Signal has no size — you can't assign to it.

  3. Signal has no purpose — just create the result.
double signal[];
    ⋮
      if(A>0) signal[0] = +1; 
      if(B>0) signal[
1] = +1;
      if(C>0) signal[
2] = -1;
      if(D>0) signal[
3] = -1;
      if(E>0) signal[
4] = -1; 

In this case how would you sum signals from different functions?

Reason: