Trying to add mobile notification function to CCI divergence indicator V 1.1 - page 2

 
Check every instance of the variable and think about what is happening with it.
 
Keith Watford #:
Check every instance of the variable and think about what is happening with it.
In all the instances, the variable has been equated to the time function array of opening price in current bar. Should I create a constant variable to use for SendNotification instead of using the alertTag.  I also thought the alertTag variable can be accessed for use in any part of the code since it's a global variable. 
 

You are not checking carefully and thinking.

Tell me what is wrong with this

 int a=2,b=1;
  bool print=true;
  bool comment=true;
  bool alerted = false;

  if(a>b && print && !alerted)
   {
    Print("True");
    alerted=true;
   }

  if(a>b && comment && !alerted)
   {
    Comment("True");
    alerted=true;
   }
 
Keith Watford #:

You are not checking carefully and thinking.

Tell me what is wrong with this

Operand of the logical negation (!). The result is TRUE (1), if the operand value is FALSE (0); and it is equal to FALSE (0), if the operand differs from FALSE (0).

Honestly this operand ! is really cracking my head the way it is inverted. 
 
Ismail Lemin #:
Operand of the logical negation (!). The result is TRUE (1), if the operand value is FALSE (0); and it is equal to FALSE (0), if the operand differs from FALSE (0).

Honestly this operand ! is really cracking my head the way it is inverted. 
If a>b and print is true(1) and alerted is not true(!) 
     print( "True") ;
     alerted =True; // will not print anything 

If a>b and comment is true(1) and alerted is not false(!) 
   comment("True") ;
   alerted = True; // will send comment to journal. 
 

Ok, try once more

  int a=2,b=1;
  bool first=true;
  bool second=true;
  bool alerted = false;

  if(a>b && first && alerted==false)
   {
    Print("First Test is True");
    alerted=true;
   }

  if(a>b && second && alerted==false)
   {
    Print("Second Test is True");
    alerted=true;
   }

Will both prints be printed?

If not - why?

 
Keith Watford #:

Ok, try once more

Will both prints be printed?

If not - why?

None of the two will print because of the alerted condition in the if statement. I have changed the operand to != and they print. Let me now go  and apply the same concept to the SendNotification lines and see how they playout. Am sure I can get the function to work thanks to your brilliant way of making me understand it. It makes so much sense now.

 
Keith Watford #:

Ok, try once more

Will both prints be printed?

If not - why?

Hey Keith, thanks for helping me with code. Not sure if I did it correctly but I declared a new variable "Notifier" and instantiated it with the SendNotification function. Now am getting notified. Could we say that once the alertTag having declared and applied to the Alert function could no longer be used in other lines of the program? I tend to think that way because all the IF conditions were true but notifications were not being sent.