Using BOOLEAN to hide indicator line.

 

Hello, I am back with another question about Booleans.

How do I use boolean to hide buffer 2 (ExtMapBuffer2). I have tried different ways and I am stumped.

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

extern bool showshift = true;
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);

return(0);
}
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;
//---- main calculation loop
      while(pos>=0)    
   {   
      dOpen = High[pos];
      dClose = Low[pos];

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

//--------------------PROBLEM CODE IS HERE--------------------------------
   if (showshift)
      {
      //indicator_color1 = Black;
      ObjectDelete(ExtMapBuffer2);
      }
//--------------------PROBLEM END------------------------------------------
      
      
   if (invert)
      {
      string short_name = "True";
      IndicatorShortName(short_name);
      }
   else
      {
      string short_nameother = "False";
      IndicatorShortName(short_nameother);
      }
return(0);
}

Again, thanks for your help.

DaveFx

 
  1. IndicatorShortName belongs in init, not start.
  2. objectDelete requires an object not a buffer. If you don't want to show a line, don't set any values in its buffer.
  3. "another question about Booleans." Don't start another post, continue the previous one.
 
WHRoeder:
  1. IndicatorShortName belongs in init, not start.
  2. objectDelete requires an object not a buffer. If you don't want to show a line, don't set any values in its buffer.
  3. "another question about Booleans." Don't start another post, continue the previous one.


Hi,

2: objectDelete requires an object not a buffer. If you don't want to show a line, don't set any values in its buffer.

Can you provide an example. I am still learning how to hide indicator lines.

3: "another question about Booleans." Don't start another post, continue the previous one.

Will do, and thanks.

 
davefx:


Hi,

2: objectDelete requires an object not a buffer. If you don't want to show a line, don't set any values in its buffer.

Can you provide an example. I am still learning how to hide indicator lines.

if it is only for hiding indicator line and you still have the buffer in the indicator so you can find the values with iCustom

then i suggest

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

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

//---- buffers
double ExtMapBuffer1[]; //Red
double ExtMapBuffer2[]; //Lime  ==> No drawing line
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_NONE);            // instead of DRAW_LINE
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexShift(1,Shift);
This way you will keep ofcours ExtMapBuffer2 and the value might appear if you point with the mouse its value but you don't see the line
 
It worked, thanks a bunch. :)
 
deVries:

if it is only for hiding indicator line and you still have the buffer in the indicator so you can find the values with iCustom

Doesn't HideTestIndicators() do that ?
 
RaptorUK:
Doesn't HideTestIndicators() do that ?


Looking to this he wrote

Hello, I am back with another question about Booleans.

How do I use boolean to hide buffer 2 (ExtMapBuffer2). I have tried different ways and I am stumped.

//--------------------PROBLEM CODE IS HERE--------------------------------
   if (showshift)
      {
      //indicator_color1 = Black;
      ObjectDelete(ExtMapBuffer2);
      }
//--------------------PROBLEM END------------------------------------------
i thought he did want to hide only the second line not the first
 
deVries:


Looking to this he wrote

Hello, I am back with another question about Booleans.

How do I use boolean to hide buffer 2 (ExtMapBuffer2). I have tried different ways and I am stumped.

i thought he did want to hide only the second line not the first


Hi,

I have searched this site for information on indicator line inverting. But cannot find anything.

In the code below, I would like to invert the second buffer (green line.) I think I know it has something to do with using the opposite OHLC values to invert the second buffer line.. But I am not sure, can you offer (again) some advice..


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

extern bool showshift = true;
extern int Shift = 1;
extern bool Showtextsepwin = false;
extern bool AccEQ = false;
extern bool invertBuffer2 = false;

//extern color AccEQLabelColor = White;
//extern string AccEQFontStyle = "FixedSys";

//---- 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);

return(0);
}
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;
//---- main calculation loop
      while(pos>=0)    
   {   
      dOpen = High[pos];
      dClose = Low[pos];
      dResult = dOpen - dClose;
      ExtMapBuffer1[pos]= dResult;
      ExtMapBuffer2[pos]= dResult;
      pos--;
         }


//-------------------------LOOK HERE-----------------------------------
   if (invertBuffer2)   
   {
         dOpen = Low[pos];
         dClose = High[pos];
         dResult = dClose - dOpen;
         ExtMapBuffer1[pos]= dResult;
         ExtMapBuffer2[pos]= dResult;
         pos--;
   }
   else
   {
         dOpen = High[pos];
         dClose = Low[pos];   
         dResult = dOpen - dClose;
         ExtMapBuffer1[pos]= dResult;
         ExtMapBuffer2[pos]= dResult;
         pos--;
   }




   if (Showtextsepwin)
      {     
      string short_name = "True";
      IndicatorShortName(short_name);
      }
   else
      {
      string short_nameother = "False";
      IndicatorShortName(short_nameother);
      }

   if (AccEQ)
      {
      int Eq1;
      Eq1 = AccountEquity();
      Comment("Equity: ", Eq1);
      }
   else
      {
      Comment("");
      }

  if (showshift)
      {
      SetIndexStyle(1,DRAW_LINE);            
      SetIndexBuffer(1,ExtMapBuffer2);
      SetIndexShift(1,Shift);           
      }
  else
      {
      SetIndexStyle(1,DRAW_NONE);            
      SetIndexBuffer(1,ExtMapBuffer2);
      SetIndexShift(1,Shift);           
      }

return(0);
}

}

Thanks a bunch you guys.

DaveFX

 
davefx:


Hi,

I have searched this site for information on indicator line inverting. But cannot find anything.

In the code below, I would like to invert the second buffer (green line.) I think I know it has something to do with using the opposite OHLC values to invert the second buffer line.. But I am not sure, can you offer (again) some advice..


Thanks a bunch you guys.

DaveFX


The best way to learn David is trie out and compare the result

You keep the original program make a copy with other name change this program and compare if the results are what you wanna have

This way you can learn yourself a lot

         dOpen = Low[pos];
         dClose = High[pos];
         dResult = dClose - dOpen;

if i wanna invert this then i think it is only to need to switch DOpen and DClose value if the value original is 10-1 (=9)

Then invert has to be 1-10 (= -9)

         dOpen = High[pos];       
         dClose = Low[pos];
         dResult = dClose - dOpen;             //inverted ???

Just trie that out and see result....

 
deVries:


The best way to learn David is trie out and compare the result

You keep the original program make a copy with other name change this program and compare if the results are what you wanna have

This way you can learn yourself a lot

if i wanna invert this then i think it is only to need to switch DOpen and DClose value if the value original is 10-1 (=9)

Then invert has to be 1-10 (= -9)

Just trie that out and see result....


Thanks. I figured it out with your help. :))
 
davefx: How do I use boolean to hide buffer 2 (ExtMapBuffer2) Can you provide an example. I am still learning how to hide indicator lines.
ExtMapBuffer1[pos]= dResult;
ExtMapBuffer2[pos]= dResult;
   ExtMapBuffer1[pos]= dResult;
if (!invertBuffer2)
   ExtMapBuffer2[pos]= dResult;

Was that so hard?