Day High Low Indicator Data Extraction for EA

 

I have found a indicator on this website which provides previous day (or week / /month) high and low prices.  I want to use this as the basis of creating my own EA to place buystops and sellstops at the previous day high and low.  

Link: https://www.mql5.com/en/code/14410

I can see the code I want to extract and connect to in my enter trade section (full code provided in the link):

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum AvailablePeriods
  {
   PreviousDay=PERIOD_D1,// Previous day
   PreviousWeek=PERIOD_W1,// Previous week
   PreviousMonth=PERIOD_MN1 // Previous month
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
struct TimeRange
  {
   bool Failed;
   datetime StartTime;
   datetime EndTime;

   TimeRange()
     {
      Failed=false;
      StartTime=0;
      EndTime=0;
     }
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
struct PeriodData
  {
   TimeRange PeriodRange;

   double PeriodHigh;
   double PeriodClose;
   double PeriodLow;

   PeriodData()
     {
      PeriodHigh=0;
      PeriodClose=0;
      PeriodLow=0;
     }
  };

input string _sepTimeShift=""; // /////// Calculation
input ENUM_TIMEFRAMES Precision=PERIOD_H1; // Precision
input AvailablePeriods TargetTimeFrame=PreviousDay; // Period
input int PeriodsToCalculate=1; // Periods to calculate
input int HoursShift=-2; // Hours shift
input int MinutesShift=0; // Minutes shift
input bool IgnoreSunday=true; // Ignore Sunday
input bool IgnoreSaturday=true; // Ignore Saturday

input string _sepBufferVisibility=""; // /////// Buffer visibility
input bool ShowHighBuffer=true; // High
input bool ShowCloseBuffer=true; // Close
input bool ShowLowBuffer=true; // Low

input string _sepProbeVisibility=""; // /////// Probe visibility
input bool ShowHighProbe=true; // High
input bool ShowCloseProbe=true; // Close
input bool ShowLowProbe=true; // Low

input string _sepProbeColor=""; // /////// Probe color
input color HighColor=C'83,173,52'; // High
input color CloseColor=C'83,173,52'; // Close
input color LowColor=C'83,173,52'; // Low

input string _sepProbeSize=""; // /////// Probe size
input int HighSize=2; // High
input int CloseSize=2; // Close
input int LowSize=2; // Low

input string _sepCustomLabel=""; // /////// Data window label
input string HighLabel="P.Day High"; // High
input string CloseLabel="P.Day Close"; // Close
input string LowLabel="P.Day Low"; // Low

string HighProbeName="HighPrevious"+IntegerToString(TargetTimeFrame)+IntegerToString(HoursShift)+IntegerToString(MinutesShift);
string CloseProbeName="ClosePrevious"+IntegerToString(TargetTimeFrame)+IntegerToString(HoursShift)+IntegerToString(MinutesShift);
string LowProbeName="LowPrevious"+IntegerToString(TargetTimeFrame)+IntegerToString(HoursShift)+IntegerToString(MinutesShift);

double PeriodHighBuffer[];
double PeriodCloseBuffer[];
double PeriodLowBuffer[];

PeriodData TempData;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
PeriodData CalculateCommonSRData(datetime targetTime,TimeRange &periodRange)
  
  {
   if(TempData.PeriodRange.StartTime==periodRange.StartTime &&
      TempData.PeriodRange.EndTime==periodRange.EndTime)
      return( TempData );

   PeriodData result;

   int firstBar= iBarShift(Symbol(),Precision,periodRange.StartTime);
   int lastBar = iBarShift(Symbol(),Precision,periodRange.EndTime);

   datetime firstBarTime= iTime(Symbol(),Precision,firstBar);
   datetime lastBarTime = iTime(Symbol(),Precision,lastBar);

   int startBar=lastBar;
   int bars=firstBar-lastBar+1;

   int highestBar= iHighest(Symbol(),Precision,MODE_HIGH,bars,startBar);
   int lowestBar = iLowest(Symbol(),Precision,MODE_LOW,bars,startBar);
   
   result.PeriodRange= periodRange;
   result.PeriodHigh = iHigh(Symbol(),Precision,highestBar);
   result.PeriodClose= iClose(Symbol(),Precision,lastBar);
   result.PeriodLow=iLow(Symbol(),Precision,lowestBar);

   TempData=result;
   return( result );
   
  }

In my enter trade section I have tried a variety of codes to link them for example: DayHigh = TempData.PeriodHigh etc.. which just returns 0.

The indicator codes looks very useful but can anyone help me use it to get the high low information to use as buy/sell stop process?

High, Low and Close of the previous day, week or month
High, Low and Close of the previous day, week or month
  • www.mql5.com
The indicator shows the High, Close and Low of the previous day, week or month. These levels are very commonly used as support and resistance among traders, so the indicator will draw them and leave a gap between periods to make it easy to distinguish when a new one started. Update 1.1: Added some optimizations. Update 1.1.1: Fixed compilation...
Reason: