[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Find_High-Low_N Modifcation Help



PureBytes Links

Trading Reference Links

Attached is some code that I think Clyde Lee may have written a while
back. It allows the user to plot horizontal lines at the top and bottom
of the range of a day, week, month,  or quarter. For quarterly
calculations, this code only allows you to specify the calendar month
that you want the quarter to begin. What I would like to do is modify
this code so that I can specify the day and the month that I want a
quarter to begin. Any help would be most appreciated.

{Indicator:   Find_High-Low_N

 This indicator allows the user to plot horizontal lines
 at the top and bottom of the range of week, month,  or
 quarter..

}


Input:  DoDay(True),
       DoWeek(True),
       DoMonth(False),  {Set true the period to be plotted.  }
       DoQtr(False),
    BegMonth(1);     {Beginning month (1=Jan/12=Dec) for  }
                       {the beginning of the quarters.  Then}
             {every 3 months thereafter           }



Vars:   MaxBarsForward(0), QuarterHi(0),  QuarterLo(0),  QuarterKnt(0),
      MonthHi(0),    MonthLo(0),    MonthKnt(0),
      WeekHi(0),     WeekLo(0),     WeekKnt(0),
      DayHi(0),      DayLo(0),      DayKnt(0);

Vars:    PriorQuarterHi(0),  PriorQuarterLo(0),  IsQuarter(0),
      PriorMonthHi(0),    PriorMonthLo(0),
      PriorWeekHi(0),     PriorWeekLo(0),
      PriorDayHi(0),      PriorDayLo(0);



If Date<>Date[1] then begin
  PriorDayHi=DayHi;
 PriorDayLo=DayLo;
 DayKnt=DayKnt+1;
 DayHi=H;
 DayLo=L;
End;
If H>DayHi then DayHi=H;
If L<DayLo then DayLo=L;

If DayOfWeek(date)<DayOfWeek(date[1]) then begin
  PriorWeekHi=WeekHi;
 PriorWeekLo=WeekLo;
 WeekKnt=WeekKnt+1;
 WeekHi=H;
 WeekLo=L;
End;
If H>WeekHi then WeekHi=H;
If L<WeekLo then WeekLo=L;

If Month(date)<>Month(date[1]) then begin
  PriorMonthHi=MonthHi;
 PriorMonthLo=MonthLo;
 MonthKnt=MonthKnt+1;
 MonthHi=H;
 MonthLo=L;
End;
If H>MonthHi then MonthHi=H;
If L<MonthLo then MonthLo=L;

IsQuarter=Mod(Month(date)-BegMonth+1,3);
If IsQuarter[1]=0 and IsQuarter=1  then begin
  PriorQuarterHi=QuarterHi;
 PriorQuarterLo=QuarterLo;
 QuarterKnt=QuarterKnt+1;
 QuarterHi=H;
 QuarterLo=L;
End;
If H>QuarterHi then QuarterHi=H;
If L<QuarterLo then QuarterLo=L;

If DoDay and DayKnt>1 then begin
 Plot3(PriorDayHi,"hi");
 Plot4(PriorDayLo,"lo");
 If LastBarOnChart and ((Time>=Sess1EndTime and Sess2EndTime>2359) or
Time>=Sess2EndTime) then begin
  For Value1=-1 downto -MaxBarsForward begin
     Plot3[Value1](DayHi,"hi");
     Plot4[Value1](DayLo,"lo");
  End;
  End;
End;

If DoWeek and WeekKnt>1 then begin
 Plot1(PriorWeekHi,"hi");
 Plot2(PriorWeekLo,"lo");
 If LastBarOnChart and DayOfWeek(date)=5 then begin
  For Value1=-1 downto -MaxBarsForward begin
     Plot1[Value1](WeekHi,"hi");
     Plot2[Value1](WeekLo,"lo");
  End;
  End;
End;

If DoMonth and MonthKnt>1 then begin
 Plot3(PriorMonthHi,"hi");
 Plot4(PriorMonthLo,"lo");
 If LastBarOnChart and
Month(date)<>Month(Juliantodate(datetojulian(date)+2)) then begin
  For Value1=-1 downto -MaxBarsForward begin
     Plot3[Value1](MonthHi,"hi");
     Plot4[Value1](MonthLo,"lo");
  End;
  End;
End;

If DoQtr and QuarterKnt>1 then begin
 Plot1(PriorQuarterHi,"hi");
 Plot2(PriorQuarterLo,"lo");
End;