//+------------------------------------------------------------------+
//|                                          FiftyTwoWeekHighLow.mq4 |
//|                                      Copyright 2018, nicholishen |
//|                                          http://forexfactory.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, nicholishen"
#property link      "http://forexfactory.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters
input color    InpHigh=clrLime; //High color
input color    InpLow=clrRed; //Low color
input int      InpW=2; //Line thickness
#include <ChartObjects\ChartObjectsLines.mqh>

CChartObjectHLine g_high, g_low;
//+------------------------------------------------------------------+
int OnInit()
{
   ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,true);
   if(!g_high.Create(0,"__high__",0,0.)
      || !g_high.Description("52 week high")
      || !g_high.Color(InpHigh)
      || !g_high.Width(InpW)
      || !g_low.Create(0,"__low__",0,0.)
      || !g_low.Description("52 week low")
      || !g_low.Color(InpLow)
      || !g_low.Width(InpW)
   )
      return INIT_FAILED;
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
int start()
{
   g_high.Price(0,
      iHigh(_Symbol, PERIOD_W1, iHighest( _Symbol, PERIOD_W1, MODE_HIGH, 52))
   );
   g_low.Price(0,
      iLow(_Symbol, PERIOD_W1, iLowest( _Symbol, PERIOD_W1, MODE_LOW, 52))
   );
   return 0;
}
//+------------------------------------------------------------------+
