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

next 3rd friday code for TS 4



PureBytes Links

Trading Reference Links

Does anyone have the code or ela for next 3rd friday for ts 4?

I have it for 2K but not able to convert it to ts 4. I am looking to 
reference the H, L , C of that day.

It is attached thanks to Clyde Lee.

Thanks
Sno



{*******************************************************************
Description : This Function returns Next3rdFriday
Provided By : Omega Research, Inc. (c) Copyright 1999
********************************************************************}

Inputs: Series(Numeric);
Variables: WorkDay(0), Month1(0), Year1(0), MonthTarget(0), DayTarget(0), 
YearTarget(0), FirstFriday(0), ThirdFriday(0), JulianTarget(0), julianNow(0), 
SZMonth(0), SZDay(0), SZYear(0), SeriesRotation(1);

SeriesRotation = Series - 1;
SZDay = DayOfMonth(Date);
SZMonth = Month(Date);
SZYear = Year(Date);

WorkDay = DayOfWeek((SZYear * 10000) + (100 * SZMonth) + 1);

If WorkDay = 0 Then 
 FirstFriday = 6;
If WorkDay = 1 Then 
 FirstFriday = 5;
If WorkDay = 2 Then 
 FirstFriday = 4;
If WorkDay = 3 Then 
 FirstFriday = 3;
If WorkDay = 4 Then 
 FirstFriday = 2;
If WorkDay = 5 Then 
 FirstFriday = 1;
If WorkDay = 6 Then 
 FirstFriday = 7;

ThirdFriday = FirstFriday + 14;

If ThirdFriday > SZDay Then Begin
 Month1 = SZMonth;
 Year1 = SZYear;
End
Else Begin
 Month1 = SZMonth + 1;
 If Month1 = 13 Then Begin
  Month1 = 1;
  Year1 = SZYear + 1;
 End
 Else Begin
  Year1 = SZYear;
 End;
End;

MonthTarget = Month1+SeriesRotation;

If MonthTarget > 12 Then Begin
 MonthTarget = MonthTarget - 12;
 YearTarget = Year1 + 1;
End
Else Begin
 YearTarget = Year1;
End;

WorkDay = DayOfWeek((YearTarget * 10000) + (100 * MonthTarget) + 1);

If WorkDay = 0 Then 
 FirstFriday = 6;
If WorkDay = 1 Then 
 FirstFriday = 5;
If WorkDay = 2 Then 
 FirstFriday = 4;
If WorkDay = 3 Then 
 FirstFriday = 3;
If WorkDay = 4 Then 
 FirstFriday = 2;
If WorkDay = 5 Then 
 FirstFriday = 1;
If WorkDay = 6 Then 
 FirstFriday = 7;

DayTarget = FirstFriday + 14;

julianNow = DateToJulian((10000 * SZYear) + (100 * SZMonth) + SZDay);
JulianTarget = DateToJulian((10000 * YearTarget) + (100 * MonthTarget) + 
DayTarget);
 
Next3rdFriday = JulianTarget-JulianNow;