questions about && - page 2

 
Marco vd Heijden:

First of all i would never use && like that.

if(xmma < xmpma)
{
  if(flma < flpma)
   {
    // Here you go...
   }
}


Second, YES you always need to verify your data.

Data Availability

Presence of data on HCC format or even in the prepared for using HC format does not always denote the absolute availability if these data to be shown in a chart or used in mql4 programs.

When accessing to price data or indicator values from a mql4 program it should be remembered that their availability in a certain moment of time or starting from a certain moment of time is not guaranteed.

If the data is not available, what is the output of your indicatior call?

Assuming that everyhing is ok at all times can be a very bad idea.

I appreciate the clear response!!!  Thank you!  I found the article you quoted and it helped further explain the background of whats going on.

https://docs.mql4.com/series/timeseries_access

Organizing Data Access - Timeseries and Indicators Access - MQL4 Reference
Organizing Data Access - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
Organizing Data Access - Timeseries and Indicators Access - MQL4 Reference
 
Marco vd Heijden: First of all i would never use && like that.
if(xmma < xmpma)
{
  if(flma < flpma)
   {
    // Here you go...
   }
}

I have read stories of Million Dollar mistakes happening due to && and &.

  1. if(xmma < xmpma && flma < flpma)
       {
        // Here you go...
       }
    This is absolutely identical to yours since February 3, 2014 (Build 600)
  2. Single ampersand is completely different.
 
whroeder1:
  1. if(xmma < xmpma && flma < flpma)
       {
        // Here you go...
       }
    This is absolutely identical to yours since February 3, 2014 (Build 600)
  2. Single ampersand is completely different.

I never said that they were different.

 
Marco vd Heijden:

First of all i would never use && like that.

if(xmma < xmpma)
{
  if(flma < flpma)
   {
    // Here you go...
   }
}


I disagree with this. I like nesting, but this is over the top. If you wanted to write a comparison method for an object with 20 instance variables your code would look weird.

Now if you are mixing multiple && with multiple || then I would have some sympathy, but not just a few && which work well together without ambiguity.

All compilers, including the MQL4 one, will warn you if you mistakenly use & instead of &&.

I would have a much bigger problem with a coder that doesn't check their compiler warnings than one that uses a standard "and" logic operator

 
Marco vd Heijden: First of all i would never use && like that.
Marco vd Heijden:
I never said that they were different.
You said that you would never use one, only the other. That implies that they are different. Make up your mind.
 
whroeder1:

You said that you would never use one, only the other. That implies that they are different. Make up your mind.

I never said that they were different.

Go read it again.
 
James Cater:


I disagree with this. I like nesting, but this is over the top. If you wanted to write a comparison method for an object with 20 instance variables your code would look weird.

Now if you are mixing multiple && with multiple || then I would have some sympathy, but not just a few && which work well together without ambiguity.

All compilers, including the MQL4 one, will warn you if you mistakenly use & instead of &&.

I would have a much bigger problem with a coder that doesn't check their compiler warnings than one that uses a standard "and" logic operator

It just comes down to personal coding style.

I do like to take one step at a time.

 
Marco vd Heijden:

It just comes down to personal coding style.

I do like to take one step at a time.

Go on, take a big leap, you can do it ;)
 
James Cater:
Go on, take a big leap, you can do it ;)
It get's confusing real fast when im working on a larger project :)
 
Marco vd Heijden: It get's confusing real fast when im working on a larger project :)
More lines is less confusing? Confused
Reason: