//+------------------------------------------------------------------+
//|                                               Daily_High_Low.mq4 |
//|                                       Copyright © Terry Nicholls |
//+------------------------------------------------------------------+
#property copyright "Copyright © Terry Nicholls // mod. fxdaytrader, http://ForexBaron.net"
#property link "http://ForexBaron.net"

// Parameters

#property indicator_chart_window

extern int TimeZoneOfData = 0; // GMT

double yesterday_high=0;
double yesterday_low=0;

double rates_d1[2][6];
double dlyh;
double dlyl;

string prefixdlh  = "_dlyh Label";
string pefixdlhl  = "_dlyh Line";
string prefixdll  = "_dlyl Label";
string prefixdlll = "_dlyl Line";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
  {

// Indicators

dlyh=0; dlyl=0;

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+

int deinit()
  {

ObjectDelete(prefixdlh);
ObjectDelete(pefixdlhl);
ObjectDelete(prefixdll);
ObjectDelete(prefixdlll);

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {

// Get new Daily prices

ArrayCopyRates(rates_d1, Symbol(), PERIOD_D1);

yesterday_high = rates_d1[1][3];
yesterday_low = rates_d1[1][2];

// Calculate Daily High/Low lines

dlyh = yesterday_high;
dlyl = yesterday_low;

// Uncomment the line below to display the data at the top of your chart

// Comment ("Yesterday's High = ",yesterday_high,"  Yesterday's Low = ",yesterday_low);

// Set Daily High/Low line labels on chart window

      if(ObjectFind(prefixdlh) != 0)
      {
      ObjectCreate(prefixdlh, OBJ_TEXT, 0, Time[20], dlyh);
      ObjectSetText(prefixdlh, "Yesterdays High", 8, "Arial", DodgerBlue);
      }
      else
      {
      ObjectMove(prefixdlh, 0, Time[20], dlyh);
      }

      if(ObjectFind(prefixdll) != 0)
      {
      ObjectCreate(prefixdll, OBJ_TEXT, 0, Time[20], dlyl);
      ObjectSetText(prefixdll, "Yesterdays Low", 8, "Arial", DodgerBlue);
      }
      else
      {
      ObjectMove(prefixdll, 0, Time[20], dlyl);
      }

// Draw Yesterday's High/Low lines on chart

      if(ObjectFind(pefixdlhl) != 0)
      {
      ObjectCreate(pefixdlhl, OBJ_HLINE, 0, Time[40], dlyh);
      ObjectSet(pefixdlhl, OBJPROP_STYLE, STYLE_DOT);
      ObjectSet(pefixdlhl, OBJPROP_WIDTH, 1);
      ObjectSet(pefixdlhl, OBJPROP_COLOR, DodgerBlue);
      }
      else
      {
      ObjectMove(pefixdlhl, 0, Time[40], dlyh);
      }

      if(ObjectFind(prefixdlll) != 0)
      {
      ObjectCreate(prefixdlll, OBJ_HLINE, 0, Time[40], dlyl);
      ObjectSet(prefixdlll, OBJPROP_STYLE, STYLE_DOT);
      ObjectSet(pefixdlhl, OBJPROP_WIDTH, 1);
      ObjectSet(prefixdlll, OBJPROP_COLOR, DodgerBlue);
      }
      else
      {
      ObjectMove(prefixdlll, 0, Time[40], dlyl);
      }

   return(0); // End program

  }

//+------------------------------------------------------------------+

