Learning logic - page 3

 

I would like to add about the section criticized by gip:

bool showEUR, showUSD, showGBP, showCHF, showJPY, showRAVI;
   if ( StringFind(Symbol(), "EUR", 0) != -1) showEUR = TRUE;
   if ( StringFind(Symbol(), "USD", 0) != -1) showUSD = TRUE;
   if ( StringFind(Symbol(), "GBP", 0) != -1) showGBP = TRUE;
   if ( StringFind(Symbol(), "CHF", 0) != -1) showCHF = TRUE;
   if ( StringFind(Symbol(), "JPY", 0) != -1) showJPY = TRUE;

Basically, to optimize calculations it would be more logical to end each if() block with break check - otherwise it turns out that all five if() operators will be passed regardless of check results.

Since break operator cannot be used here directly, this block can be easily built into some loop. Here is, say, a "loop" variant:

bool showEUR, showUSD, showGBP, showCHF, showJPY, showRAVI;
   while( true )
   {
      if (  StringFind(Symbol(), "EUR", 0) != -1) ) 
      {  
         showEUR = TRUE;         break; 
      }   
      if (  StringFind(Symbol(), "USD", 0) != -1) )
      {
         showUSD = TRUE;         break;
      }   
      if (  StringFind(Symbol(), "GBP", 0) != -1) )
      {
         showGBP = TRUE;         break;
      }   
      if (  StringFind(Symbol(), "CHF", 0) != -1) )
      {
         showCHF = TRUE;         break;
      }   
      if (  StringFind(Symbol(), "JPY", 0) != -1) )
      {
         showJPY = TRUE;         break;
      }   
   }   
   

Of course, initialization of logical variables is desirable, it's true.

And it would be quite brief, if you write these string names of currencies in an array-constant and pass through it in a natural loop.

P.S. I've now understood my mistake: I should at least pass at least two if()'s :) Nevertheless, this can be optimized too, by cutting off checks after finding two currencies in a pair.

 
age_nt:

Thanks Dimitri for your attention...I respect your knowledge....and humour of course.

Couldn't appreciate it - no MSoffffffis installed


Here http://www.twirpx.com/file/86887/?rand=1440166 is a textbook on formal logic in djvu format. "Kirillov V.I., Starchenko A.A. Logic" is a logic textbook for lawyers. This book will be better. I myself once started with it.
 
Logically, we shouldn't all be here.
 
You don't have to speak for everyone. I'm being consistent and logical here :) Peter and Victor too, I guess. I don't know about the others.
 
denis_orlov:
Logically, we shouldn't all be here.


==++

Not everyone is logically capable of starting from the beginning. From the first post. Like Chukchi - what I see, what I sing...

 
nikost:


==++

Not everyone can logically start from the beginning. From the first post. Like Chukchi - what I see, what I sing...

You're the Chukcha!)

The topicstarter should start, but he announced it and disappeared, so the public is getting impatient...

 
drknn:

Here http://www.twirpx.com/file/86887/?rand=1440166 is a textbook on formal logic in djvu format. "Kirillov V.I., Starchenko A.A. Logic" is a logic textbook for lawyers. This book will be better. I myself once started with it.

Thank you Vladimir!
 

Gentlemen, please don't attack each other, or I will delete all unnecessary posts. And don't get emotional. A thread is a thread.

 
A branch is like a branch. Only already moderated :)
 

Tomorrow I will try to redo this indicator https://www.mql5.com/ru/code/9751.

The relevant factor will be the calculation time. The faster the better. But the rendering should be maintained. We may call it homework (to find variants to reduce calculation time).

The indicator just happened to be the last one in CodeBase, so I apologize to the author.