//+------------------------------------------------------------------+
//|                                            VM_Price_action v 1.2 |
//|                               Copyright © 2007, Victor Maranhão. |
//|                                              vmaranhao@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Victor Maranhão."
#property link      "vmaranhao@gmail.com"

/*============================================================
==============================================================

HISTORY

v. 1.2 

- TBL, TBH stars not showing fixed

v. 1.1

- OB changed to Bearish Outside Vertical Bar (BeOVB) and
                Bullish Outside Vertical Bar (BuOVB)

- Market Structure High / Low included

==============================================================
============================================================*/

#property indicator_chart_window
#property indicator_buffers 6

#define cIX_BF_DBHLC   0
#define cIX_BF_PINUPDN 1
#define cIX_BF_IBIBS4  2
#define cIX_BF_BOVB    3
#define cIX_BF_MSHL    4
#define cIX_BF_TBHTBL  5

#define cINDICNUM 12

#define cIX_IB     0
#define cIX_IBS4   1
#define cIX_MSL    2
#define cIX_MSH    3
#define cIX_TBH    4
#define cIX_TBL    5
#define cIX_DBHLC  6
#define cIX_DBLHC  7
#define cIX_PINUP  8
#define cIX_PINDN  9
#define cIX_BuOVB 10
#define cIX_BeOVB 11

extern bool  pDBHLC_Show        =        TRUE;
extern int   pDBHLC_Max_Delta   =           0;  // pip
extern color pDBHLC_Color       =      Yellow;
extern int   pDBHLC_Width       =           2; 

extern bool  pDBLHC_Show        =        TRUE;
extern int   pDBLHC_Max_Delta   =           0;  // pip

extern bool  pPINUP_Show        =        TRUE;
extern int   pPINUP_Min_Delta   =           5;  // pip
extern int   pPINUP_Top_Precent =          10;  // percent
extern color pPINUP_Color       =        Gold;
extern int   pPINUP_Width       =           2; 

extern bool  pPINDN_Show        =        TRUE;
extern int   pPINDN_Min_Delta   =           5;  // pip
extern int   pPINDN_Top_Precent =          10;  // percent

extern bool  pIBS4_Show         =        TRUE;
extern int   pIBS4_Min_Delta    =           0;  // pip
extern color pIBS4_Color        =   OrangeRed;
extern int   pIBS4_Width        =           2; 

extern bool  pIB_Show           =        TRUE;
extern int   pIB_Min_Delta      =           0;  // pip

extern bool  pBuOVB_Show        =        TRUE;
extern int   pBuOVB_Min_Delta   =           0;  // pip
extern color pBuOVB_Color       = NavajoWhite;
extern int   pBuOVB_Width       =           2; 

extern bool  pBeOVB_Show        =        TRUE;
extern int   pBeOVB_Min_Delta   =           0;  // pip

extern bool  pMSH_Show          =        TRUE;
extern color pMSH_Color         =  Aquamarine;
extern int   pMSH_Width         =           2; 

extern bool  pMSL_Show          =        TRUE;

extern bool  pTBH_Show          =        TRUE;
extern int   pTBH_Max_Delta     =           0;  // pip
extern color pTBH_Color         =     Magenta;
extern int   pTBH_Width         =           2; 

extern bool  pTBL_Show          =        TRUE;
extern int   pTBL_Max_Delta     =           0;  // pip

extern bool  pStats_Show        =        TRUE;
extern int   pStats_Pos         =          13;

double buffBOVB   [];
double buffMSHL   [];
double buffDBHLC  [];
double buffIBIBS4 [];
double buffTBHTBL [];
double buffPINUPDN[];

static string lblName [cINDICNUM];
static bool   lblShow [cINDICNUM]; 
static string lblText [cINDICNUM];
static color  lblColor[cINDICNUM];
static int    lblCount[cINDICNUM];
static string alrtText[cINDICNUM];

static double gDistArrow =    0;
static bool   gFirstTime = TRUE;
static int    gTimeFrame =    0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()

  {

   string title = "Price Action 1";

   gFirstTime = TRUE;
      
   gDistArrow = Point * (0 + MathSqrt(Period()));
   
   IndicatorBuffers(6);
   
   IndicatorShortName(title);

   SetIndexBuffer    (cIX_BF_BOVB   , buffBOVB   );
   SetIndexBuffer    (cIX_BF_MSHL   , buffMSHL   );
   SetIndexBuffer    (cIX_BF_DBHLC  , buffDBHLC  );
   SetIndexBuffer    (cIX_BF_IBIBS4 , buffIBIBS4 );
   SetIndexBuffer    (cIX_BF_TBHTBL , buffTBHTBL );
   SetIndexBuffer    (cIX_BF_PINUPDN, buffPINUPDN);
 
   SetIndexStyle     (cIX_BF_BOVB   , DRAW_ARROW, EMPTY, pBuOVB_Width, pBuOVB_Color);
   SetIndexStyle     (cIX_BF_MSHL   , DRAW_ARROW, EMPTY, pMSH_Width  , pMSH_Color  );
   SetIndexStyle     (cIX_BF_DBHLC  , DRAW_ARROW, EMPTY, pDBHLC_Width, pDBHLC_Color);
   SetIndexStyle     (cIX_BF_IBIBS4 , DRAW_ARROW, EMPTY, pIBS4_Width , pIBS4_Color );
   SetIndexStyle     (cIX_BF_TBHTBL , DRAW_ARROW, EMPTY, pTBH_Width  , pTBH_Color  );
   SetIndexStyle     (cIX_BF_PINUPDN, DRAW_ARROW, EMPTY, pPINUP_Width, pPINUP_Color);

   SetIndexArrow     (cIX_BF_BOVB   , 171);
   SetIndexArrow     (cIX_BF_MSHL   , 171);
   SetIndexArrow     (cIX_BF_DBHLC  , 171);
   SetIndexArrow     (cIX_BF_IBIBS4 , 171);
   SetIndexArrow     (cIX_BF_TBHTBL , 171);
   SetIndexArrow     (cIX_BF_PINUPDN, 171);
 
   SetIndexLabel     (cIX_BF_BOVB   , "Bullish/Bearish Outside V Bar");
   SetIndexLabel     (cIX_BF_MSHL   , "Market Structure High / Low");
   SetIndexLabel     (cIX_BF_DBHLC  , "DBHLC / DBLHC"                );
   SetIndexLabel     (cIX_BF_IBIBS4 , "Inside Bar / IB Smallest of 4");
   SetIndexLabel     (cIX_BF_TBHTBL , "Two Bars High / Low"          );
   SetIndexLabel     (cIX_BF_PINUPDN, "PIN Up / Down"                );
 
   SetIndexDrawBegin (cIX_BF_BOVB   , 0);
   SetIndexDrawBegin (cIX_BF_MSHL   , 0);
   SetIndexDrawBegin (cIX_BF_DBHLC  , 0);
   SetIndexDrawBegin (cIX_BF_IBIBS4 , 0);
   SetIndexDrawBegin (cIX_BF_TBHTBL , 0);
   SetIndexDrawBegin (cIX_BF_PINUPDN, 0);
   
   Set_Label_Objects_Alerts();

   return(0);

  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int deinit()

  {

   for (int ix = 0; ix < cINDICNUM; ix++)
     if (ObjectFind(lblName[ix]) != -1)
       ObjectDelete(lblName[ix]);

   return(0);
      
  }
  
//+------------------------------------------------------------------+
//| Start
//+------------------------------------------------------------------+

int start()
  {
  
          int      limit;
          int      found;
          int      countedBars = IndicatorCounted();
   static datetime prevTime    = 0;
   static double   deltaIB     = 0;
   static double   deltaTBH    = 0;
   static double   deltaTBL    = 0;
   static double   deltaIBS4   = 0;
   static double   deltaDBHLC  = 0;
   static double   deltaDBLHC  = 0;
   static double   deltaPINUP  = 0;
   static double   deltaPINDN  = 0;
   static double   deltaBuOVB  = 0;
   static double   deltaBeOVB  = 0;
   
   if (countedBars < 0) return(-1);
   if (countedBars > 0) countedBars--;
   if (Period() != gTimeFrame) 
     {
      gFirstTime = TRUE;
      prevTime = 0;
     }
     
   if (prevTime == Time[0]) return (0);
   
   prevTime = Time[0];
           
   if (countedBars > 0) countedBars--; 

   if (gFirstTime) 
     {
      Define_Min_PIN (deltaPINUP, deltaPINDN);
      deltaIB    = pIB_Min_Delta    * Point;
      deltaTBH   = pTBH_Max_Delta   * Point;
      deltaTBL   = pTBL_Max_Delta   * Point;
      deltaIBS4  = pIBS4_Min_Delta  * Point;
      deltaDBHLC = pDBHLC_Max_Delta * Point;
      deltaDBLHC = pDBLHC_Max_Delta * Point;
      deltaBuOVB = pBuOVB_Min_Delta * Point;
      deltaBeOVB = pBeOVB_Min_Delta * Point;
     }

   limit = Bars - countedBars;
   
   for (int ix1 = 1; ix1 <= limit; ix1++)
     {
      found = -1;
      if (                  pDBHLC_Show ) found = Find_DBHLC (ix1, deltaDBHLC);
      if ((found == -1) && (pDBLHC_Show)) found = Find_DBLHC (ix1, deltaDBLHC);
      if ((found == -1) && (pPINUP_Show)) found = Find_PINUp (ix1, deltaPINUP);
      if ((found == -1) && (pPINDN_Show)) found = Find_PINDn (ix1, deltaPINDN);
      if ((found == -1) && (pMSH_Show  )) found = Find_MSH   (ix1            );
      if ((found == -1) && (pMSL_Show  )) found = Find_MSL   (ix1            );
      if ((found == -1) && (pIBS4_Show )) found = Find_IBS4  (ix1, deltaIBS4 );
      if ((found == -1) && (pIB_Show   )) found = Find_IB    (ix1, deltaIB   );
      if ((found == -1) && (pBuOVB_Show)) found = Find_BuOVB (ix1, deltaBuOVB);
      if ((found == -1) && (pBeOVB_Show)) found = Find_BeOVB (ix1, deltaBeOVB);
      if ((found == -1) && (pTBH_Show  )) found = Find_TBH   (ix1, deltaTBH  );
      if ((found == -1) && (pTBL_Show  )) found = Find_TBL   (ix1, deltaTBL  );
      if  (found != -1)                   lblCount[found]++;
      if  (gFirstTime )                   continue;
      if ((found != -1) && (ix1 < 2    )) 
        Alert(Symbol()," (",Period(),") - ", alrtText[found]);
     }

   Set_Labels();
     
   gFirstTime = FALSE;

   gTimeFrame = Period();
   
   return(0);

  }

//+------------------------------------------------------------------+
//+  Find Double Bar High, Lower Close (DBHLC)
//+------------------------------------------------------------------+

int Find_DBHLC(int ix1, double delta)

  {

   double dif;
   
   dif = MathAbs(iHigh (NULL,0,ix1) - iHigh(NULL,0,ix1+1));
   
   if (dif > delta) return (-1);

   if (iClose(NULL,0,ix1) >= iLow(NULL,0,ix1+1)) return (-1);
   
   buffDBHLC[ix1] = iHigh(NULL,0,ix1) + gDistArrow;

   return (cIX_DBHLC);
   
  }

//+------------------------------------------------------------------+
//+  Find Double Bar Low, Higher Close (DBLHC)
//+------------------------------------------------------------------+

int Find_DBLHC(int ix1, double delta)

  {

   double dif;
   
   dif = MathAbs(iLow (NULL,0,ix1) - iLow(NULL,0,ix1+1));

   if (dif > delta) return (-1);

   if (iClose(NULL,0,ix1) <= iHigh(NULL,0,ix1+1)) return (-1);

   buffDBHLC[ix1] = iLow(NULL,0,ix1) - gDistArrow;

   return (cIX_DBLHC);
   
  }

//+------------------------------------------------------------------+
//+  Find PIN Up (PinUp)
//+------------------------------------------------------------------+

int Find_PINUp (int ix1, double delta)

  {

   if (iOpen (NULL,0,ix1) > iHigh(NULL,0,ix1+1)        ) return (-1);
   if (iOpen (NULL,0,ix1) < iLow (NULL,0,ix1+1)        ) return (-1);
   if (iClose(NULL,0,ix1) > iHigh(NULL,0,ix1+1)        ) return (-1);
   if (iClose(NULL,0,ix1) < iLow (NULL,0,ix1+1)        ) return (-1);
   if (iLow  (NULL,0,ix1) < iLow (NULL,0,ix1+1)        ) return (-1);
   if (iHigh (NULL,0,ix1) < iHigh(NULL,0,ix1+1) + delta) return (-1);
   
   buffPINUPDN[ix1] = iHigh(NULL,0,ix1) + gDistArrow;
   
   return (cIX_PINUP);
   
  }

//+------------------------------------------------------------------+
//+  Find PIN Up (PinDn)
//+------------------------------------------------------------------+

int Find_PINDn(int ix1, double delta)

  {

   if (iOpen (NULL,0,ix1) > iHigh(NULL,0,ix1+1)        ) return (-1);
   if (iOpen (NULL,0,ix1) < iLow (NULL,0,ix1+1)        ) return (-1);
   if (iClose(NULL,0,ix1) > iHigh(NULL,0,ix1+1)        ) return (-1);
   if (iClose(NULL,0,ix1) < iLow (NULL,0,ix1+1)        ) return (-1);
   if (iHigh (NULL,0,ix1) > iHigh(NULL,0,ix1+1)        ) return (-1);
   if (iLow  (NULL,0,ix1) > iLow (NULL,0,ix1+1) - delta) return (-1);
   
   buffPINUPDN[ix1] = iLow(NULL,0,ix1) - gDistArrow;
   
   return (cIX_PINDN);
   
  }

//+------------------------------------------------------------------+
//+  Find Inside Bar, Smallest of 4 (IBS4)
//+------------------------------------------------------------------+
  
int Find_IBS4(int ix1, double delta)
  
  {
   
   double range = iHigh(NULL,0,ix1) - iLow(NULL,0,ix1) + delta;
   
   if (range > iHigh(NULL,0,ix1+3) - iLow(NULL,0,ix1+3)) return (-1);
    
   if (range > iHigh(NULL,0,ix1+2) - iLow(NULL,0,ix1+2)) return (-1);

   if (range > iHigh(NULL,0,ix1+1) - iLow(NULL,0,ix1+1)) return (-1);

   if (iHigh(NULL,0,ix1) > iHigh(NULL,0,ix1+1)) return (-1);

   if (iLow (NULL,0,ix1) < iLow (NULL,0,ix1+1)) return (-1);
   
   buffIBIBS4[ix1] = iHigh(NULL,0,ix1) + gDistArrow;
   
   return (cIX_IBS4);
   
  }
  
//+------------------------------------------------------------------+
//+  Find Inside Bar (IB)
//+------------------------------------------------------------------+
  
int Find_IB(int ix1, double delta)
  
  {
   
   if (iHigh(NULL,0,ix1) + delta >= iHigh(NULL,0,ix1+1)) return (-1);
   
   if (iLow (NULL,0,ix1) - delta <= iLow (NULL,0,ix1+1)) return (-1);
    
   buffIBIBS4[ix1] = iLow(NULL,0,ix1) - gDistArrow;
   
   return (cIX_IB);
   
  }
  
//+------------------------------------------------------------------+
//+  Find Bullish Outside Vertical Bar (BuOVB)
//+------------------------------------------------------------------+
  
int Find_BuOVB (int ix1, double delta)
  
  {
   
   if (iHigh (NULL,0,ix1) <= iHigh (NULL,0,ix1+1) + delta) return (-1);

   if (iLow  (NULL,0,ix1) >= iLow  (NULL,0,ix1+1) - delta) return (-1);

   if (iClose(NULL,0,ix1) <= iClose(NULL,0,ix1+1)        ) return (-1);
   
   buffBOVB[ix1] = iHigh(NULL,0,ix1) + gDistArrow;
   
   return (cIX_BuOVB);
   
  }
  
//+------------------------------------------------------------------+
//+  Find Bearish Outside Vertical Bar (BeOVB)
//+------------------------------------------------------------------+
  
int Find_BeOVB (int ix1, double delta)
  
  {
   
   if (iHigh (NULL,0,ix1) <= iHigh (NULL,0,ix1+1) + delta) return (-1);

   if (iLow  (NULL,0,ix1) >= iLow  (NULL,0,ix1+1) - delta) return (-1);

   if (iClose(NULL,0,ix1) >= iClose(NULL,0,ix1+1)        ) return (-1);
       
   buffBOVB[ix1] = iLow(NULL,0,ix1) - gDistArrow;
   
   return (cIX_BeOVB);
   
  }
  
//+------------------------------------------------------------------+
//+  Find Market Structure High (MSH)
//+------------------------------------------------------------------+
  
int Find_MSH (int ix1)
  
  {
   
   if (iClose (NULL,0,ix1+2) <= iOpen  (NULL,0,ix1+2)) return (-1);
   if (iClose (NULL,0,ix1+1) <= iOpen  (NULL,0,ix1+1)) return (-1);
   if (iClose (NULL,0,ix1  ) >= iOpen  (NULL,0,ix1  )) return (-1);
   
   if (iHigh  (NULL,0,ix1+2) >= iHigh  (NULL,0,ix1+1)) return (-1);
   if (iLow   (NULL,0,ix1+2) >= iLow   (NULL,0,ix1+1)) return (-1);

   if (iHigh  (NULL,0,ix1+1) <= iHigh  (NULL,0,ix1  )) return (-1);

   buffMSHL[ix1] = iHigh(NULL,0,ix1) + gDistArrow;
   
   return (cIX_MSH);
   
  }
  
//+------------------------------------------------------------------+
//+  Find Market Structure High (MSL)
//+------------------------------------------------------------------+
  
int Find_MSL (int ix1)
  
  {
   
   if (iClose (NULL,0,ix1+2) >= iOpen  (NULL,0,ix1+2)) return (-1);
   if (iClose (NULL,0,ix1+1) >= iOpen  (NULL,0,ix1+1)) return (-1);
   if (iClose (NULL,0,ix1  ) <= iOpen  (NULL,0,ix1  )) return (-1);
   
   if (iHigh  (NULL,0,ix1+2) <= iHigh  (NULL,0,ix1+1)) return (-1);
   if (iLow   (NULL,0,ix1+2) <= iLow   (NULL,0,ix1+1)) return (-1);

   if (iLow   (NULL,0,ix1+1) >= iLow   (NULL,0,ix1  )) return (-1);

   buffMSHL[ix1] = iLow(NULL,0,ix1) - gDistArrow;
   
   return (cIX_MSL);
   
  }
  
//+------------------------------------------------------------------+
//+  Find Two Bars High (TBH)
//+------------------------------------------------------------------+
  
int Find_TBH(int ix1, double delta)
  
  {
   
   double dif;
   
   dif = MathAbs(iHigh(NULL,0,ix1) - iHigh(NULL,0,ix1+1));

   if (dif > delta) return (-1);
    
   buffTBHTBL[ix1] = iHigh(NULL,0,ix1) + gDistArrow;
   
   return (cIX_TBH);
   
  }
  
//+------------------------------------------------------------------+
//+  Find Two Bars Low (TBH)
//+------------------------------------------------------------------+
  
int Find_TBL(int ix1, double delta)
  
  {
   
   double dif;
   
   dif = MathAbs(iLow(NULL,0,ix1) - iLow(NULL,0,ix1+1));

   if (dif > delta) return (-1);
    
   buffTBHTBL[ix1] = iLow(NULL,0,ix1) - gDistArrow;
   
   return (cIX_TBL);
   
  }
  
//+------------------------------------------------------------------+
//+  Define Minimum PIN Up and Down
//+------------------------------------------------------------------+
  
void Define_Min_PIN(double& resultUp, double& resultDn)
  
  {
   int    contUp[500];
   int    contDn[500];
   int    contaUp;
   int    contaDn;
   int    totalUp;
   int    totalDn;
   double deltaUp = pPINUP_Min_Delta * Point;
   double deltaDn = pPINDN_Min_Delta * Point;
   int    fator = MathPow(10,Digits);
   int    contIx;
   int    limit;
   int    countedBars = IndicatorCounted();
    
   ArrayInitialize(contUp,0);
   
   limit = Bars - countedBars;
   
   for (int ix1 = 0; ix1 < limit; ix1++)
     { 
      if (iOpen (NULL,0,ix1) > iHigh(NULL,0,ix1+1)) continue;
      if (iOpen (NULL,0,ix1) < iLow (NULL,0,ix1+1)) continue;
      if (iClose(NULL,0,ix1) > iHigh(NULL,0,ix1+1)) continue;
      if (iClose(NULL,0,ix1) < iLow (NULL,0,ix1+1)) continue;
      
      if ((iLow  (NULL,0,ix1) >= iLow (NULL,0,ix1+1)) &&
          (iHigh (NULL,0,ix1) >= iHigh(NULL,0,ix1+1) + deltaUp))
        {
         contIx = (iHigh(NULL,0,ix1)-iHigh(NULL,0,ix1+1)) * fator;
         contUp[contIx]++;
         totalUp++;
         continue;
        }
       
      if ((iHigh(NULL,0,ix1) <= iHigh(NULL,0,ix1+1)) &&
          (iLow (NULL,0,ix1) <= iLow (NULL,0,ix1+1) - deltaDn))
        {
         contIx = (iLow(NULL,0,ix1+1)-iLow(NULL,0,ix1)) * fator;
         contDn[contIx]++;
         totalDn++;
        }
     } 

   totalUp = (totalUp / 100) * pPINUP_Top_Precent;
   totalDn = (totalDn / 100) * pPINDN_Top_Precent;
   
   for (int ix2 = ArrayRange(contUp,0); ix2 >= 0; ix2--)
     {
      contaUp = contaUp + contUp[ix2];
      if (contaUp >= totalUp)
        {
         resultUp = ix2 * Point;
         break;
        }
      }
   
   for (int ix3 = ArrayRange(contDn,0); ix3 >= 0; ix3--)
     {
      contaDn = contaDn + contDn[ix3];
      if (contaDn >= totalDn)
        {
         resultDn = ix3 * Point;
         break;
        }
      }

  }

//+------------------------------------------------------------------+
//+  Set Labels
//+------------------------------------------------------------------+

void Set_Labels ()

  {
   
   string txt;
   
   for (int ix = 0; ix < cINDICNUM; ix++)
     if (lblShow[ix])
       {
        txt = lblText[ix] + lblCount[ix] + ")";
        ObjectSetText(lblName[ix],txt,9,"Verdana",lblColor[ix]);
       }
    
  }
  
//+------------------------------------------------------------------+
//+  Set Label Objects and Alert Texts
//+------------------------------------------------------------------+

void Set_Label_Objects_Alerts()

  {
  
   int ix;
   int dst = pStats_Pos;
   
   for (ix = 0; ix < cINDICNUM; ix++)
     lblName[ix] = "VMPA" + ix;

   for (ix = 0; ix < cINDICNUM; ix++)
     if (ObjectFind(lblName[ix]) != -1)
       ObjectDelete(lblName[ix]);

   if (!pStats_Show) return;
   
   lblShow[cIX_IB   ] =    pIB_Show;
   lblShow[cIX_MSL  ] =   pMSL_Show;
   lblShow[cIX_MSH  ] =   pMSH_Show;
   lblShow[cIX_TBH  ] =   pTBH_Show;
   lblShow[cIX_TBL  ] =   pTBL_Show;
   lblShow[cIX_IBS4 ] =  pIBS4_Show;
   lblShow[cIX_BuOVB] = pBuOVB_Show;
   lblShow[cIX_BeOVB] = pBeOVB_Show;
   lblShow[cIX_DBHLC] = pDBHLC_Show;
   lblShow[cIX_DBLHC] = pDBLHC_Show;
   lblShow[cIX_PINUP] = pPINUP_Show;
   lblShow[cIX_PINDN] = pPINDN_Show;

   lblColor[cIX_IB   ] =  pIBS4_Color;
   lblColor[cIX_MSL  ] =   pMSH_Color;
   lblColor[cIX_MSH  ] =   pMSH_Color;
   lblColor[cIX_TBH  ] =   pTBH_Color;
   lblColor[cIX_TBL  ] =   pTBH_Color;
   lblColor[cIX_IBS4 ] =  pIBS4_Color;
   lblColor[cIX_BuOVB] = pBuOVB_Color;
   lblColor[cIX_BeOVB] = pBuOVB_Color;
   lblColor[cIX_DBHLC] = pDBHLC_Color;
   lblColor[cIX_DBLHC] = pDBHLC_Color;
   lblColor[cIX_PINUP] = pPINUP_Color;
   lblColor[cIX_PINDN] = pPINUP_Color;

   lblText[cIX_IB   ] =     "IB (";
   lblText[cIX_MSL  ] =    "MSL (";
   lblText[cIX_MSH  ] =    "MSH (";
   lblText[cIX_TBH  ] =    "TBH (";
   lblText[cIX_TBL  ] =    "TBL (";
   lblText[cIX_IBS4 ] =   "IBS4 (";
   lblText[cIX_BuOVB] =  "BuOVB (";
   lblText[cIX_BeOVB] =  "BeOVB (";
   lblText[cIX_DBHLC] =  "DBHLC (";
   lblText[cIX_DBLHC] =  "DBLHC (";
   lblText[cIX_PINUP] = "Pin Up (";
   lblText[cIX_PINDN] = "Pin Dn (";

   alrtText[cIX_IB   ] = " Inside Bar.";
   alrtText[cIX_MSL  ] = " Market Structure Low.";
   alrtText[cIX_MSH  ] = " Market Structure High.";
   alrtText[cIX_TBH  ] = " Two Bar High.";
   alrtText[cIX_TBL  ] = " Two Bar low.";
   alrtText[cIX_IBS4 ] = " Inside Bar Smallest of 4.";
   alrtText[cIX_BuOVB] = " Bullish Outside Vertical Bar.";
   alrtText[cIX_BeOVB] = " Bearish Outside Vertical Bar.";
   alrtText[cIX_DBHLC] = " Double Bars High Lower Close.";
   alrtText[cIX_DBLHC] = " Double Bars Low Higher Close.";
   alrtText[cIX_PINUP] = " Pin Up.";
   alrtText[cIX_PINDN] = " Pin Dn.";

   for (ix = 0; ix < cINDICNUM; ix++)
     if (lblShow[ix])
       {
        dst = dst + 13;
        ObjectCreate (lblName[ix],OBJ_LABEL        ,  0,0,0);
        ObjectSet    (lblName[ix],OBJPROP_CORNER   ,  0);
        ObjectSet    (lblName[ix],OBJPROP_XDISTANCE, 10);
        ObjectSet    (lblName[ix],OBJPROP_YDISTANCE, dst);
        ObjectSetText(lblName[ix],lblText[ix],9,"Verdana",lblColor[ix]);
       }
    
   }