Need some advice on BOOLEANS.

 

Hi,

I am trying to write my first indicator. Well, I am just playing with code and having some fun.

I would like to display a message box when the specified parameter is TRUE and when I okay the parameter box.

Below is the code, it does not do a lot.

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Lime

extern int Shift = 1;
extern bool invert = false;
//extern int MA_Method = 10;

//---- buffers
double ExtMapBuffer1[]; //Red
double ExtMapBuffer2[]; //Lime
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexShift(1,Shift);


string short_name = "Your first indicator is running!";
IndicatorShortName(short_name);

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();



//---- check for possible errors
if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if (counted_bars>0) counted_bars--;
      int pos=Bars-counted_bars;
      double dOpen , dClose , dResult;
      Comment("Hi! I'm here on the main chart windows!");
    
//---- main calculation loop
      while(pos>=0)
   
    
   {   
      dOpen = High[pos];
      dClose = Low[pos];

      dResult = dOpen - dClose;
      ExtMapBuffer1[pos]= dResult;
      ExtMapBuffer2[pos]= dResult;
      pos--;
   }



//-----I AM HAVING TROUBLE WITH THIS CODE FRAGMENT--------------------------------------------------------
   if (invert) == true;
      {
      MessageBox("hello", "hello");
      }
//------------------------------------FRAGMENT END-------------------------------------------------------




//----
//----
return(0);

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

If you clever people can help then thank you.

Davefx out.

 
davefx:

Hi,

I am trying to write my first indicator. Well, I am just playing with code and having some fun.

I would like to display a message box when the specified parameter is TRUE and when I okay the parameter box.

Below is the code, it does not do a lot.

Try this . . . but bear in mind that Message Box does not produce any output in the Strategy Tester . . .

if (invert);                           //  same as if( invert == true)
      {
      MessageBox("hello", "hello");
      }
 
if (invert) == true;
  1. You wouldn't ever code IF ( (2+2 == 4) == True). Of course not IF ( 2+2 == 4 ) is sufficient. If (Bool) or if (!bool) is all you need.
    if (invert){ MessageBox(...); }
  2. Always use self explanatory names. such as if (DisplayBox){ ... }
 
WHRoeder:
  1. You wouldn't ever code IF ( (2+2 == 4) == True). Of course not IF ( 2+2 == 4 ) is sufficient. If (Bool) or if (!bool) is all you need.
  2. Always use self explanatory names. such as if (DisplayBox){ ... }

Many Thanks.