what function should use if want to choose 4 out of 7

 

I have this 7 value

example

 A,B,C,D,E,F,G

if value of A,B,D,E is more than 1 (or)

if value of B,D,E,F is more than 1 (or)

if value of C,E,F,G is more than 1


I mean when any 4 value out of 7 > 1

how can made this condition by mql4

thanks

 

LONNV:

if value of A,B,D,E is more than 1 (or)

if value of B,D,E,F is more than 1 (or)

if value of C,E,F,G is more than 1


I mean when any 4 value out of 7 > 1

how can made this condition by mql4

  1. If you don't need to differentiate A-E vs C-G. Just count them.
  2. If you do, test A-E. Then add F and test. Then add G and test.
  3. You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help (2017.04.21)

 
LONNV:

I have this 7 value

example

 A,B,C,D,E,F,G

if value of A,B,D,E is more than 1 (or)

if value of B,D,E,F is more than 1 (or)

if value of C,E,F,G is more than 1


I mean when any 4 value out of 7 > 1

how can made this condition by mql4

thanks

An easy way could be to create an array of 1's and 0's and simply add them up - if the total == 4 then the condition is met.

Script attached as example (sorry it is MQL5 - I do not have  a MQL4 environment, but I hope it helps)

//+------------------------------------------------------------------+
//|                                                  test4outof7.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
#define  def_size      7
#define  def_threshold 4

   int   dataSet[def_size] = {};

   Print("\n\n//--Random Data:");
   for(int i = 0; i < def_size; i++)
     {
      dataSet[i] = (MathMod(MathRand(), 2) == 0) ? 0 : 1;
      PrintFormat("[%d]=%d", i, dataSet[i]);
     }


   int index   = 0;
   int oneValues = 0;

   while(index < def_size)
     {
      oneValues += dataSet[index];
      index++;
     }

   PrintFormat("Dataset contains %d \"1's\"",  oneValues);

   PrintFormat("Checking for exactly %d = %s", def_threshold, 
   (oneValues == def_threshold) ? "TRUE" : "FALSE"
   );


  }
//+------------------------------------------------------------------+