
// +----------------------------------------------------------------------------------------+ //
// |                                     XARD GANNLINE 50  \¦/                              | //
// |                            Knowledge of the ancients (ò ó)                             | //
// |_________________________________________________o0o___(_)___o0o________________________| //
// |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____|_____| //
// |                                                                                XARD777 | //
// |----------------------------------------------------------------------------------------| //
// | Programming language:     MQL4                                                         | //
// | Development platform:     MetaTrader 4                                                 | //
// |          End product:     Indicator for MetaTrader 4 designed                          | //
// |                           for Build 226 (current version)                              | //
// +----------------------------------------------------------------------------------------+ //

#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1 C'255,255,255'
#property indicator_color2  Red
#property indicator_color3  Blue

#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3

// ------------------------------------------------------------------------------------------ //
//                            E X T E R N A L   V A R I A B L E S                             //
// ------------------------------------------------------------------------------------------ //

//extern int Lb = 50;
         
// ------------------------------------------------------------------------------------------ //
//                            I N T E R N A L   V A R I A B L E S                             //
// ------------------------------------------------------------------------------------------ //
int Lb;
double Xardcol100;
double ssla[],sslb[],sslc[],Hld,Hlv;

// ------------------------------------------------------------------------------------------ //
//                             I N I T I A L I S A T I O N                                    //
// ------------------------------------------------------------------------------------------ //

int init()
  {
//---- indicators
   IndicatorBuffers(3);

   SetIndexBuffer(0,sslc);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexArrow(0, 159);
   
   SetIndexBuffer(1,ssla);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexArrow(1, 159);

   SetIndexBuffer(2,sslb);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexArrow(2, 159);

      switch ( Period() )
         {
          case 5: Lb =  300;break;
          case 15:Lb =  100;break;
          default:Lb =  50;break;
         }

   return(0);
  }

// ------------------------------------------------------------------------------------------ //
//                            D E - I N I T I A L I S A T I O N                               //
// ------------------------------------------------------------------------------------------ //

int deinit()
  {
//----
  ObjectDelete("Bar50");
  ObjectDelete("Bar50t"); 
//----
   return(0);
  }

// ------------------------------------------------------------------------------------------ //
//                                M A I N   P R O C E D U R E                                 //
// ------------------------------------------------------------------------------------------ //

int start()
  {

   for(int i=Bars-Lb;i>=0;i--)
   {
      if(Close[i]>iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_HIGH,i+1)) Hld = 1;
      else 
      {
       if(Close[i]<iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_LOW,i+1)) Hld = -1;
       else
       Hld = 0;
      }
      
      if(Hld!=0)
      Hlv = Hld;
            
      if(Hlv == -1){
         sslc[i] = iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_HIGH,i+1);
         ssla[i] = iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_HIGH,i+1);
         Xardcol100 = indicator_color2;
      }else{
         sslc[i] = iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_LOW,i+1);
         sslb[i] = iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_LOW,i+1);
         Xardcol100 = indicator_color3;
      }
   }
   
   
   return(0);
  }
// ------------------------------------------------------------------------------------------ //
//                                     E N D   P R O G R A M                                  //
// ------------------------------------------------------------------------------------------ //

