Loop needs to only print 1 z

 
//+------------------------------------------------------------------+
//|                                                     question.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
// A:
   for(int x=0; x<100; x++)
      if(x==1)
         for(int y=0; y<100; y++)
            if(y>x) // DEAL WITH THE PREVIOUS DETERMINED X AND FINALLY
              {
               Print("y ",y);
               break; // PRINTS Y ONLY ONCE CORRECT
              }

// B:
   for(int x=0; x<100; x++)
      if(x==1)
         for(int y=0; y<100; y++)
            if(y>x) // DEAL WITH THE PREVIOUS DETERMINED X AND FINALLY
               for(int z=0; z<100; z++)
                  if(z>y) // DEAL WITH THE PREVIOUS DETERMINED Y AND FINALLY
                    {
                     Print("z ",y); // PRINT ONLY FIRST Z THAT IS ABOVE Y WHICH IS ABOVE X
                     break; // !!!!! ONLY ONCE THOUGH !!! THIS ONE PRINTS MANY Z's; NOT CORRECT
                    }

//2 versions; A stops at 2 and B does not. Why does the first A only print one iteration of y and the B iterates many iterations of z? I need B. to behave like A and only print ONCE the z value that is larger than x and y
  }
//+------------------------------------------------------------------+
THX! just one z necessary prints like 100 anyone know how to just print once z above y? Is this worth it or just have it break and save to variables faster bc break ends the whole loop?
 
nadiawicket:
THX! just one z necessary prints like 100 anyone know how to just print once z above y? Is this worth it or just have it break and save to variables faster bc break ends the whole loop?
faster bc break ends the whole loop?

What is a faster bc?

 
Keith Watford:

What is a faster bc?

bc = because

      for(int x=0; x<100; x++)
         if(x==1)
           {
            x1=1;
            break;
           }

      for(int y=0; y<100; y++)
         if(y>x1)
           {
            Print("y ",y);
            break;
           }

as in this instead and just stop the for loops to make it faster? 

Code profiling - Developing programs - MetaEditor Help
Code profiling - Developing programs - MetaEditor Help
  • www.metatrader5.com
Profiling means collecting program parameters during its execution. During a profiling, the execution time and the number of calls of individual functions and program code lines are measured. With this tool, the programmer is able to find and optimize the slowest code sections. Profiling can be performed on the normal chart of the trading...
 
nadiawicket:
THX! just one z necessary prints like 100 anyone know how to just print once z above y? Is this worth it or just have it break and save to variables faster bc break ends the whole loop?
you have not put an end to y iteration after z condition is met
 
roshjardine:
you have not put an end to y iteration after z condition is met


OK looks to be the case
 
nadiawicket:

how do i do that why doesnt break take care of it like before that now is the next step

tried to move brackets around not it 

from y is equal to 2 until 98 is valid for z is equal to 3 until 99,that is what i understand from your code
 
roshjardine:
from y is equal to 2 until 98 is valid for z is equal to 3 until 99,that is what i understand from your code

all until a hundred supposed to be

 
nadiawicket:

all until a hundred supposed to be

your last stop is 99 and your count is 100
 
roshjardine:
your last stop is 99 and your count is 100

yes 99 ok not exactly 100 

      for(int x=0; x<100; x++)
         if(x==1)
            for(int y=0; y<100; y++)
               if(y>x) // DEAL WITH THE PREVIOUS DETERMINED X AND FINALLY
                 {
                  for(int z=0; z<100; z++)
                     if(z>y) // DEAL WITH THE PREVIOUS DETERMINED Y AND FINALLY
                       {
                        Print(__LINE__," ",GetLastError()," ",GetMicrosecondCount()," z ",z," ",GetMicrosecondCount()," ",GetLastError());
                        break; // !!!!! ONLY ONCE THOUGH !!! THIS ONE PRINTS MANY Z's; NOT CORRECT
                       }
                  break;
                 }
 
nadiawicket:

yes 99 ok not exactly 100 

int tempz;
         for(int x=0; x<100; x++)
          {
            int o = 0;
            int p = 0;
            
            if (x==1)
            {
               for(int y=0;y<100;y++)
               {
                  if (y>x&&o<1)
                  {
                     o += 1;
                     for(int z=0;z<100;z++)
                     {
                        if (z>y&&p<1)
                        {
                           p += 1;
                           Print("z:",z);
                           tempz = z;
                        }   
                     }
                     Print("y:",y);
                  }   
                  continue;
                  
               }
               Print("x:",x);
               }
               continue;               
           }  
   
           Print(__LINE__," ",GetLastError()," ",GetMicrosecondCount()," to get z value which is ",tempz," it took ",GetMicrosecondCount()," ms ",GetLastError()); 
 
nadiawicket:

bc = because

Then please write because instead of bc.

I am English and I could not make sense of your sentence.

Imagine how it can be for non native English speakers and there are many that use this forum.

Reason: