Futures rollover webpage/stick thread - Commodities Futures Trading | futures io social day trading
futures io futures trading


Futures rollover webpage/stick thread
Updated: Views / Replies:3,136 / 12
Created: by RM99 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Futures rollover webpage/stick thread

  #1 (permalink)
Fortitudo et Honor
Austin, TX
 
Futures Experience: Advanced
Platform: TradeStation
Favorite Futures: Futures
 
Posts: 882 since Mar 2011
Thanks: 128 given, 703 received

Futures rollover webpage/stick thread

I thought with all the brain horsepower on futures.io (formerly BMT), we could come up with a better resource for quick reference with respect to rollover dates.

I have an indicator (someone else wrote it) that gives me "days to rollover" that I run on my chart for CL. Now that I'm actually starting to venture out from CL, I found that a singular reference that has all the necessary information would be most helpful.

There are webpages like this Futures Expiration Dates

But it requires click and drop down etc.

Does anyone else think that a singular page that lists:

Current Symbol, expiration date, days to rollover

We could do this for various common instruments (CL, GC, NG, FDAX, NQ, ES, 6E, TF, YM, Brent, Silver, etc).

Obviously, some work would have to go into the coding, cause the number of days to rollover would be preferable in trading days (rather than calendar days) which also takes into account scheduled holidays for the particular exchage that hosts the instrument.

What are your thoughts?

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


The rollover question is simple for some of the futures contracts (including all the financials and precious metals) and it is difficult for physically traded commodities such as crude oil and the agriculturals.

I doubt that you can code an algorithm, which does it all.

Let us take CL. First you need to look up the last trade date and the first notice date. The rollover date needs to be prior to both these dates. Then the question is whether you use that rollover date

-> to roll your position (you will have a look at liquidity)
-> or to build a backadjusted contract (the offset depends on the rollover date)

For rolling my position, I will use some discretion, as for example that Cushing delivery is totally insane, so I would rather roll early than late, to avoid potential trouble during the last days of trading of that CL contract. I would be less concerned to roll a position late in Brent Crude traded at IPE.

I have never succeeded to find an algorithm for CL.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #4 (permalink)
Fortitudo et Honor
Austin, TX
 
Futures Experience: Advanced
Platform: TradeStation
Favorite Futures: Futures
 
Posts: 882 since Mar 2011
Thanks: 128 given, 703 received


Fat Tails View Post
The rollover question is simple for some of the futures contracts (including all the financials and precious metals) and it is difficult for physically traded commodities such as crude oil and the agriculturals.

I doubt that you can code an algorithm, which does it all.

Let us take CL. First you need to look up the last trade date and the first notice date. The rollover date needs to be prior to both these dates. Then the question is whether you use that rollover date

-> to roll your position (you will have a look at liquidity)
-> or to build a backadjusted contract (the offset depends on the rollover date)

For rolling my position, I will use some discretion, as for example that Cushing delivery is totally insane, so I would rather roll early than late, to avoid potential trouble during the last days of trading of that CL contract. I would be less concerned to roll a position late in Brent Crude traded at IPE.

I have never succeeded to find an algorithm for CL.

When I construct my custom contracts in CL, I have them roll 2 days prior to expiration (@CLV11=102XC). Waiting for volume superiority places you too close to trouble.

The sticky page or webpage wouldn't even have to be coded. It could simply be updated each day with number of days till rollover (or expiration) indicated.

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
 
  #5 (permalink)
Fortitudo et Honor
Austin, TX
 
Futures Experience: Advanced
Platform: TradeStation
Favorite Futures: Futures
 
Posts: 882 since Mar 2011
Thanks: 128 given, 703 received

Here is a rollover indicator for CL futures. I'm in contact with the author (Dennis) on TS forums. I'll see if he has updated the suri function.
 
Code
// Indicator: dhDaysToExpiration 
// Dennis H: 2011 
// Plots the trading days to the expiration date or the first notice date, whichever comes first 
// Gives an alert AlertDays before expiration/first-notice 
// Uses the suri.isTradingDay function to find holidays and weekends 
 
Input:  
 AlertDays(2); 
 
Var: 
 ExpJDate(0), 
 ThisJDate(0), 
 DiffDays(0), 
 Count(0), 
 IntmdtDate(0), 
 DaysToExp(0); 
 
once begin 
 if FND > 0 then ExpJDate = DateToJulian(MinList(ExpDate, FND)) 
  else ExpJDate = DateToJulian(ExpDate); 
 ThisJDate = DateToJulian(Date); 
 DiffDays = ExpJDate - ThisJDate; 
 if DiffDays >= 1 then begin 
  for Count = 1 to DiffDays begin 
   IntmdtDate = JulianToDate(ExpJDate - Count); 
   if suri.isTradingDay(IntmdtDate) = 1 then DaysToExp = DaysToExp + 1; 
  end; 
 end; 
end; 
 
if Date > Date[1] then begin  
 ThisJDate = DateToJulian(Date); 
 DiffDays = ExpJDate - ThisJDate; 
 DaysToExp = 0; 
 if DiffDays >= 1 then begin 
  for Count = 1 to DiffDays begin 
   IntmdtDate = JulianToDate(ExpJDate - Count); 
   if suri.isTradingDay(IntmdtDate) = 1 then DaysToExp = DaysToExp + 1; 
  end; 
 end; 
end; 
  
Plot1(DaysToExp, "DaysToExp"); 
Plot2(0, "0"); 
 
if CheckAlert and DaysToExp <= AlertDays then Alert("Rollover Alert: " + SymbolRoot);

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
 
  #6 (permalink)
Fortitudo et Honor
Austin, TX
 
Futures Experience: Advanced
Platform: TradeStation
Favorite Futures: Futures
 
Posts: 882 since Mar 2011
Thanks: 128 given, 703 received

Here is the suri function. It only includes holidays through 2011. The code is starting to get beyond my admitted capabilities. Maybe someone can modify/update it to include 2012, 2013, etc. (and still function properly).

 
Code
{
suri.isTradingDay
written by 
deMicron ("Suri Duddella")
Jan. 04, 2008
suriNotes.com, suriNotes, Stock Research, Futures Trading, Emini Trading, Tradestation, Indicators
Returns: 0 for Holiday, 1 = Trading Day, 0.5 = EarlyClose/HalfDay, -1: Not in the DateList
Example:
 Day = suri.IsTradingDay(1080219);
 Day = suri.IsTradingDay(1051225);

1998 to 2007 Data Compiled from $INDU 5m Charts on TS.. Suri
2008, 2009 Data Manually compiled from NYSE Calendar .. Suri
}
//Input: checkDate(numericsimple), d1(numericSimple), d2(numericsimple);
Input: checkDate(numericsimple);
// Input: checkDate(numericsimple);
Arrays: HOLIDAYS[200,2](0);
Var: count(0), Found (0), hreturn(0), iStart(0), iEnd(0);
 
// 0 = Holiday, 1 = TradingDay, 0.5= HalfDay/EarlyClose ... 
// 1998
 HOLIDAYS[   1,1] =  980101; HOLIDAYS[   1,2] = 0;
 HOLIDAYS[   2,1] =  980119; HOLIDAYS[   2,2] = 0;
 HOLIDAYS[   3,1] =  980216; HOLIDAYS[   3,2] = 0;
 HOLIDAYS[   4,1] =  980410; HOLIDAYS[   4,2] = 0;
 HOLIDAYS[   5,1] =  980525; HOLIDAYS[   5,2] = 0;
 HOLIDAYS[   6,1] =  980703; HOLIDAYS[   6,2] = 0;
 HOLIDAYS[   7,1] =  980907; HOLIDAYS[   7,2] = 0;
 HOLIDAYS[   8,1] =  981126; HOLIDAYS[   8,2] = 0;
 HOLIDAYS[   9,1] =  981127; HOLIDAYS[   9,2] = 0.5;
 HOLIDAYS[  10,1] =  981224; HOLIDAYS[  10,2] = 0.5;
 HOLIDAYS[  11,1] =  981225; HOLIDAYS[  11,2] = 0;
// 1999
 HOLIDAYS[  12,1] =  990101; HOLIDAYS[  12,2] = 0;
 HOLIDAYS[  13,1] =  990118; HOLIDAYS[  13,2] = 0;
 HOLIDAYS[  14,1] =  990215; HOLIDAYS[  14,2] = 0;
 HOLIDAYS[  15,1] =  990402; HOLIDAYS[  15,2] = 0;
 HOLIDAYS[  16,1] =  990531; HOLIDAYS[  16,2] = 0;
 HOLIDAYS[  17,1] =  990705; HOLIDAYS[  17,2] = 0;
 HOLIDAYS[  18,1] =  990906; HOLIDAYS[  18,2] = 0;
 HOLIDAYS[  19,1] =  991125; HOLIDAYS[  19,2] = 0;
 HOLIDAYS[  20,1] =  991126; HOLIDAYS[  20,2] = 0.5;
 HOLIDAYS[  21,1] =  991224; HOLIDAYS[  21,2] = 0;
 HOLIDAYS[  22,1] =  991231; HOLIDAYS[  22,2] = 0.5;
 // 2000
 HOLIDAYS[  23,1] = 1000117; HOLIDAYS[  23,2] = 0;
 HOLIDAYS[  24,1] = 1000221; HOLIDAYS[  24,2] = 0;
 HOLIDAYS[  25,1] = 1000421; HOLIDAYS[  25,2] = 0;
 HOLIDAYS[  26,1] = 1000529; HOLIDAYS[  26,2] = 0;
 HOLIDAYS[  27,1] = 1000703; HOLIDAYS[  27,2] = 0.5;
 HOLIDAYS[  28,1] = 1000704; HOLIDAYS[  28,2] = 0;
 HOLIDAYS[  29,1] = 1000904; HOLIDAYS[  29,2] = 0;
 HOLIDAYS[  30,1] = 1001123; HOLIDAYS[  30,2] = 0;
 HOLIDAYS[  31,1] = 1001124; HOLIDAYS[  31,2] = 0.5;
 HOLIDAYS[  32,1] = 1001225; HOLIDAYS[  32,2] = 0;
 //2001
 HOLIDAYS[  33,1] = 1010101; HOLIDAYS[  33,2] = 0;
 HOLIDAYS[  34,1] = 1010115; HOLIDAYS[  34,2] = 0;
 HOLIDAYS[  35,1] = 1010219; HOLIDAYS[  35,2] = 0;
 HOLIDAYS[  36,1] = 1010413; HOLIDAYS[  36,2] = 0;
 HOLIDAYS[  37,1] = 1010528; HOLIDAYS[  37,2] = 0;
 HOLIDAYS[  38,1] = 1010703; HOLIDAYS[  38,2] = 0.5;
 HOLIDAYS[  39,1] = 1010704; HOLIDAYS[  39,2] = 0;
 HOLIDAYS[  40,1] = 1010903; HOLIDAYS[  40,2] = 0;
 HOLIDAYS[  41,1] = 1010911; HOLIDAYS[  41,2] = 0;  //Sept. 11
 HOLIDAYS[  42,1] = 1010912; HOLIDAYS[  42,2] = 0;
 HOLIDAYS[  43,1] = 1010913; HOLIDAYS[  43,2] = 0;
 HOLIDAYS[  44,1] = 1010914; HOLIDAYS[  44,2] = 0;
 HOLIDAYS[  45,1] = 1011122; HOLIDAYS[  45,2] = 0;
 HOLIDAYS[  46,1] = 1011123; HOLIDAYS[  46,2] = 0.5;
 HOLIDAYS[  47,1] = 1011224; HOLIDAYS[  47,2] = 0.5;
 HOLIDAYS[  48,1] = 1011225; HOLIDAYS[  48,2] = 0;
 //2002
 HOLIDAYS[  49,1] = 1020101; HOLIDAYS[  49,2] = 0;
 HOLIDAYS[  50,1] = 1020121; HOLIDAYS[  50,2] = 0;
 HOLIDAYS[  51,1] = 1020218; HOLIDAYS[  51,2] = 0;
 HOLIDAYS[  52,1] = 1020329; HOLIDAYS[  52,2] = 0;
 HOLIDAYS[  53,1] = 1020527; HOLIDAYS[  53,2] = 0;
 HOLIDAYS[  54,1] = 1020704; HOLIDAYS[  54,2] = 0;
 HOLIDAYS[  55,1] = 1020705; HOLIDAYS[  55,2] = 0.5;
 HOLIDAYS[  56,1] = 1020902; HOLIDAYS[  56,2] = 0;
 HOLIDAYS[  57,1] = 1021128; HOLIDAYS[  57,2] = 0;
 HOLIDAYS[  58,1] = 1021129; HOLIDAYS[  58,2] = 0.5;
 HOLIDAYS[  59,1] = 1021224; HOLIDAYS[  59,2] = 0.5;
 HOLIDAYS[  60,1] = 1021225; HOLIDAYS[  60,2] = 0;
 //2003
 HOLIDAYS[  61,1] = 1030101; HOLIDAYS[  61,2] = 0;
 HOLIDAYS[  62,1] = 1030120; HOLIDAYS[  62,2] = 0;
 HOLIDAYS[  63,1] = 1030217; HOLIDAYS[  63,2] = 0;
 HOLIDAYS[  64,1] = 1030418; HOLIDAYS[  64,2] = 0;
 HOLIDAYS[  65,1] = 1030526; HOLIDAYS[  65,2] = 0;
 HOLIDAYS[  66,1] = 1030703; HOLIDAYS[  66,2] = 0.5;
 HOLIDAYS[  67,1] = 1030704; HOLIDAYS[  67,2] = 0;
 HOLIDAYS[  68,1] = 1030901; HOLIDAYS[  68,2] = 0;
 HOLIDAYS[  69,1] = 1031127; HOLIDAYS[  69,2] = 0;
 HOLIDAYS[  70,1] = 1031128; HOLIDAYS[  70,2] = 0.5;
 HOLIDAYS[  71,1] = 1031224; HOLIDAYS[  71,2] = 0.5;
 HOLIDAYS[  72,1] = 1031225; HOLIDAYS[  72,2] = 0;
 HOLIDAYS[  73,1] = 1031226; HOLIDAYS[  73,2] = 0.5;
 //2004
 HOLIDAYS[  74,1] = 1040101; HOLIDAYS[  74,2] = 0;
 HOLIDAYS[  75,1] = 1040119; HOLIDAYS[  75,2] = 0;
 HOLIDAYS[  76,1] = 1040216; HOLIDAYS[  76,2] = 0;
 HOLIDAYS[  77,1] = 1040409; HOLIDAYS[  77,2] = 0;
 HOLIDAYS[  78,1] = 1040531; HOLIDAYS[  78,2] = 0;
 HOLIDAYS[  79,1] = 1040611; HOLIDAYS[  79,2] = 0; // Ronald Reagan's
 HOLIDAYS[  80,1] = 1040705; HOLIDAYS[  80,2] = 0;
 HOLIDAYS[  81,1] = 1040906; HOLIDAYS[  81,2] = 0;
 HOLIDAYS[  82,1] = 1041125; HOLIDAYS[  82,2] = 0;
 HOLIDAYS[  83,1] = 1041126; HOLIDAYS[  83,2] = 0.5;
 HOLIDAYS[  84,1] = 1041224; HOLIDAYS[  84,2] = 0;
 //2005
 HOLIDAYS[  85,1] = 1050117; HOLIDAYS[  85,2] = 0;
 HOLIDAYS[  86,1] = 1050221; HOLIDAYS[  86,2] = 0;
 HOLIDAYS[  87,1] = 1050325; HOLIDAYS[  87,2] = 0;
 HOLIDAYS[  88,1] = 1050530; HOLIDAYS[  88,2] = 0;
 HOLIDAYS[  89,1] = 1050704; HOLIDAYS[  89,2] = 0;
 HOLIDAYS[  90,1] = 1050905; HOLIDAYS[  90,2] = 0;
 HOLIDAYS[  91,1] = 1051124; HOLIDAYS[  91,2] = 0;
 HOLIDAYS[  92,1] = 1051125; HOLIDAYS[  92,2] = 0.5;
 HOLIDAYS[  93,1] = 1051226; HOLIDAYS[  93,2] = 0;
 //2006
 HOLIDAYS[  94,1] = 1060102; HOLIDAYS[  94,2] = 0;
 HOLIDAYS[  95,1] = 1060116; HOLIDAYS[  95,2] = 0;
 HOLIDAYS[  96,1] = 1060220; HOLIDAYS[  96,2] = 0;
 HOLIDAYS[  97,1] = 1060414; HOLIDAYS[  97,2] = 0;
 HOLIDAYS[  98,1] = 1060529; HOLIDAYS[  98,2] = 0;
 HOLIDAYS[  99,1] = 1060703; HOLIDAYS[  99,2] = 0.5;
 HOLIDAYS[ 100,1] = 1060704; HOLIDAYS[ 100,2] = 0;
 HOLIDAYS[ 101,1] = 1060904; HOLIDAYS[ 101,2] = 0;
 HOLIDAYS[ 102,1] = 1061123; HOLIDAYS[ 102,2] = 0;
 HOLIDAYS[ 103,1] = 1061124; HOLIDAYS[ 103,2] = 0.5;
 HOLIDAYS[ 104,1] = 1061225; HOLIDAYS[ 104,2] = 0;
 //2007
 HOLIDAYS[ 105,1] = 1070101; HOLIDAYS[ 105,2] = 0;
 HOLIDAYS[ 106,1] = 1070102; HOLIDAYS[ 106,2] = 0; // Gerald Ford's
 HOLIDAYS[ 107,1] = 1070105; HOLIDAYS[ 107,2] = 0;
 HOLIDAYS[ 108,1] = 1070115; HOLIDAYS[ 108,2] = 0;
 HOLIDAYS[ 109,1] = 1070219; HOLIDAYS[ 109,2] = 0;
 HOLIDAYS[ 110,1] = 1070406; HOLIDAYS[ 110,2] = 0;
 HOLIDAYS[ 111,1] = 1070528; HOLIDAYS[ 111,2] = 0;
 HOLIDAYS[ 112,1] = 1070703; HOLIDAYS[ 112,2] = 0.5;
 HOLIDAYS[ 113,1] = 1070704; HOLIDAYS[ 113,2] = 0;
 HOLIDAYS[ 114,1] = 1070903; HOLIDAYS[ 114,2] = 0;
 HOLIDAYS[ 115,1] = 1071122; HOLIDAYS[ 115,2] = 0;
 HOLIDAYS[ 116,1] = 1071123; HOLIDAYS[ 116,2] = 0.5;
 HOLIDAYS[ 117,1] = 1071224; HOLIDAYS[ 117,2] = 0.5;
 HOLIDAYS[ 118,1] = 1071225; HOLIDAYS[ 118,2] = 0;
 // Manual Entries for 2008, 2009 Holidays from NYSE Calendar... Suri
 // 2008
 HOLIDAYS[ 119,1] = 1080101; HOLIDAYS[ 119,2] = 0;
 HOLIDAYS[ 120,1] = 1080121; HOLIDAYS[ 120,2] = 0;
 HOLIDAYS[ 121,1] = 1080218; HOLIDAYS[ 121,2] = 0;
 HOLIDAYS[ 122,1] = 1080321; HOLIDAYS[ 122,2] = 0;
 HOLIDAYS[ 123,1] = 1080526; HOLIDAYS[ 123,2] = 0;
 HOLIDAYS[ 124,1] = 1080703; HOLIDAYS[ 124,2] = 0.5;
 HOLIDAYS[ 125,1] = 1080704; HOLIDAYS[ 125,2] = 0;
 HOLIDAYS[ 126,1] = 1080901; HOLIDAYS[ 126,2] = 0;
 HOLIDAYS[ 127,1] = 1081127; HOLIDAYS[ 127,2] = 0;
 HOLIDAYS[ 128,1] = 1081127; HOLIDAYS[ 128,2] = 0;
 HOLIDAYS[ 129,1] = 1081128; HOLIDAYS[ 129,2] = 0.5;
 HOLIDAYS[ 130,1] = 1081224; HOLIDAYS[ 130,2] = 0.5;
 HOLIDAYS[ 131,1] = 1081225; HOLIDAYS[ 131,2] = 0;
// 2009
 HOLIDAYS[ 132,1] = 1090101; HOLIDAYS[ 132,2] = 0;
 HOLIDAYS[ 133,1] = 1090119; HOLIDAYS[ 133,2] = 0;
 HOLIDAYS[ 134,1] = 1090216; HOLIDAYS[ 134,2] = 0;
 HOLIDAYS[ 135,1] = 1090410; HOLIDAYS[ 135,2] = 0;
 HOLIDAYS[ 136,1] = 1090525; HOLIDAYS[ 136,2] = 0;
 HOLIDAYS[ 137,1] = 1090703; HOLIDAYS[ 137,2] = 0;
 HOLIDAYS[ 138,1] = 1090907; HOLIDAYS[ 138,2] = 0;
 HOLIDAYS[ 139,1] = 1091126; HOLIDAYS[ 139,2] = 0;
 HOLIDAYS[ 140,1] = 1091127; HOLIDAYS[ 140,2] = 0.5;
 HOLIDAYS[ 141,1] = 1091224; HOLIDAYS[ 141,2] = 0.5;
 HOLIDAYS[ 142,1] = 1091225; HOLIDAYS[ 142,2] = 0;
 
 // 2010
 HOLIDAYS[ 143,1] = 1100101; HOLIDAYS[ 143,2] = 0;
 HOLIDAYS[ 144,1] = 1100118; HOLIDAYS[ 144,2] = 0;
 HOLIDAYS[ 145,1] = 1100215; HOLIDAYS[ 145,2] = 0;
 HOLIDAYS[ 146,1] = 1100402; HOLIDAYS[ 146,2] = 0;
 HOLIDAYS[ 147,1] = 1100531; HOLIDAYS[ 147,2] = 0;
 HOLIDAYS[ 148,1] = 1100705; HOLIDAYS[ 148,2] = 0;
 HOLIDAYS[ 149,1] = 1100906; HOLIDAYS[ 149,2] = 0;
 HOLIDAYS[ 150,1] = 1101125; HOLIDAYS[ 150,2] = 0;
 HOLIDAYS[ 151,1] = 1101126; HOLIDAYS[ 151,2] = 0.5;
 HOLIDAYS[ 152,1] = 1101224; HOLIDAYS[ 152,2] = 0;
  // 2011
 HOLIDAYS[ 153,1] = 1110117; HOLIDAYS[ 153,2] = 0;
 HOLIDAYS[ 154,1] = 1110221; HOLIDAYS[ 154,2] = 0;
 HOLIDAYS[ 155,1] = 1110422; HOLIDAYS[ 155,2] = 0;
 HOLIDAYS[ 156,1] = 1110530; HOLIDAYS[ 156,2] = 0;
 HOLIDAYS[ 157,1] = 1110704; HOLIDAYS[ 157,2] = 0;
 HOLIDAYS[ 158,1] = 1110905; HOLIDAYS[ 158,2] = 0;
 HOLIDAYS[ 159,1] = 1111124; HOLIDAYS[ 159,2] = 0;
 HOLIDAYS[ 160,1] = 1111125; HOLIDAYS[ 160,2] = 0.5;
 HOLIDAYS[ 161,1] = 1111226; HOLIDAYS[ 161,2] = 0;
 
 
 if checkDate >= 980101 and checkDate <= 981231 then
 begin
  iStart = 1;
 iEnd = 11;
 end
 else if checkDate >= 990101 and checkDate <= 991231 then
 begin
  iStart = 12;
 iEnd = 22;
 end  else if checkDate >= 1000101 and checkDate <= 1001231 then
 begin
  iStart = 23;
 iEnd = 32;
 end  else if checkDate >= 1010101 and checkDate <= 1011231 then
 begin
  iStart = 33;
 iEnd = 48;
 end   else if checkDate >= 1020101 and checkDate <= 1021231 then
 begin
  iStart = 49;
 iEnd = 60;
 end  else if checkDate >= 1030101 and checkDate <= 1031231 then
 begin
  iStart = 61;
 iEnd = 73;
 end  else if checkDate >= 1040101 and checkDate <= 1041231 then
 begin
  iStart = 74;
 iEnd = 84;
 end  else if checkDate >= 1050101 and checkDate <= 1051231 then
 begin
  iStart = 85;
 iEnd = 93;
 end  else if checkDate >= 1060101 and checkDate <= 1061231 then
 begin
  iStart = 94;
 iEnd = 104;
 end  else if checkDate >= 1070101 and checkDate <= 1071231 then
 begin
  iStart = 105;
 iEnd = 118;
 end  else if checkDate >= 1080101 and checkDate <= 1081231 then
 begin
  iStart = 119;
 iEnd = 131;
 end   else if checkDate >= 1090101 and checkDate <= 1091231 then
 begin
  iStart = 132;
 iEnd = 142;
 end   else if checkDate >= 1100101 and checkDate <= 1101231 then
 begin
  iStart = 143;
 iEnd = 152;
 end   else if checkDate >= 1110101 and checkDate <= 1111231 then
 begin
  iStart = 153;
 iEnd = 161;
 end

 else  // Out of the range of this DB...
 begin
  iStart = 0;
 iEnd = 0;
 Found = -100;
 hreturn = -1;  // Not In DB 
 end;
  
 
if ((DayOfWeek(checkDate) = 0) OR (DayOfWeek(checkDate) = 6)) then  // Saturady or Sunday
begin
 hreturn = 0;   // Saturday, Sunday... 
end
else if (iStart > 0 and iEnd > 0) then
begin
 Found=-1;  
 for count= iStart to iEnd
 begin
  value10 = IntPortion(Holidays[count,1]);
  if (value10 = Intportion(checkDate)) then
  begin  
   Found =1;  
   hreturn = HOLIDAYS[count,2];
   count=10000; // Short-Circuit
  end;
 end;
 if (Found =-1) then  // Not a Holiday
  hreturn = 1; // Full-Trading Day
end;
suri.isTradingDay = hreturn; 
 

// print("TestD  = ", checkDate, " DayofWeek  = ", DayOfWeek(checkDate));   
// print("Count = ", count, "HC = ", Holidays[count,1]);    
// print("Found = ", " Count = ", Count);   
// print("hreturn = ", hreturn);
// print("Istart = ", istart, " iEnd = ", Iend);

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
 
  #7 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received

Hey,
I think that it is a great idea to have functions for both rollovers and holidays.
I'm interested in coding this for NT.
As a rule I don't code indicators, only if its necessary for my strategies, but I think first we need to agree on functions that can be called from any indicator. After we'll have those functions anyone will be able to code his own indicator that meets his/her needs.
The way to do it I think is by creating "csv" file.
For holidays I propose this format:
1. Exchange/Instrument - "All" for all instruments.
2. Date in format YYYYMMDD
3. Close time in format HHMM. "Zero" for full holiday.

For rollovers we need two files.
File 1:
1. Instrument/Instrument category (indexes, currencies, CL...)
2. Last trade date YYYYMMDD
3. First notice date YYYYMMDD
4. Contract month MMDD

File 2:
1. Instrument/Instrument category (indexes, currencies, CL...)
2. Rollover advance in days. ##

Instrument which doesn't need the rollover file will be calculated inside the function. Still they can exist in file 2.
That way each trader will be able to tweak it for his/her personal preferences.

Tell me what you think.

Baruch
p.s. All times will be in ET.

Reply With Quote
The following user says Thank You to baruchs for this post:
 
  #8 (permalink)
Fortitudo et Honor
Austin, TX
 
Futures Experience: Advanced
Platform: TradeStation
Favorite Futures: Futures
 
Posts: 882 since Mar 2011
Thanks: 128 given, 703 received


baruchs View Post
Hey,
I think that it is a great idea to have functions for both rollovers and holidays.
I'm interested in coding this for NT.
As a rule I don't code indicators, only if its necessary for my strategies, but I think first we need to agree on functions that can be called from any indicator. After we'll have those functions anyone will be able to code his own indicator that meets his/her needs.
The way to do it I think is by creating "csv" file.
For holidays I propose this format:
1. Exchange/Instrument - "All" for all instruments.
2. Date in format YYYYMMDD
3. Close time in format HHMM. "Zero" for full holiday.

For rollovers we need two files.
File 1:
1. Instrument/Instrument category (indexes, currencies, CL...)
2. Last trade date YYYYMMDD
3. First notice date YYYYMMDD
4. Contract month MMDD

File 2:
1. Instrument/Instrument category (indexes, currencies, CL...)
2. Rollover advance in days. ##

Instrument which doesn't need the rollover file will be calculated inside the function. Still they can exist in file 2.
That way each trader will be able to tweak it for his/her personal preferences.

Tell me what you think.

Baruch
p.s. All times will be in ET.

To be honest with you, I'm a mile wide and an inch deep when it comes to coding. I know enough to accomplish many of the things that I need and only some of the things I would like.

The code above works, how it translates to C, is beyond me. But like I said, I have to get in touch with the author and see if he has an updated version of the suri function that has the holiday schedule out past the end of this year.

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
 
  #9 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received


Quoting 
To be honest with you, I'm a mile wide and an inch deep when it comes to coding. I know enough to accomplish many of the things that I need and only some of the things I would like.

The code above works, how it translates to C, is beyond me. But like I said, I have to get in touch with the author and see if he has an updated version of the suri function that has the holiday schedule out past the end of this year.

No offense, but my proposal was not for you. It is for a small community of Ninja traders on this forum.

Baruch

Reply With Quote
 
  #10 (permalink)
Elite Member
NORTH ATTLEBORO
 
Futures Experience: Intermediate
Platform: nt
Favorite Futures: 02760
 
Posts: 4 since Aug 2011
Thanks: 3 given, 0 received


if you can follow the logic, this works for the ES in eSignal, determines the next expiry date, the thursday the week before the third friday of mar jun sep and dec, year independent.

var Third_Friday = exp = null; var YY = DD = MM = expY = expT = 0;

function preMain() {
setPriceStudy(true);
setStudyTitle("ExpCalc");
debugClear();
}

function main() {
//if(getBarState() == BARSTATE_ALLBARS)return
if ( getBarState() == BARSTATE_NEWBAR && getMinute() == 30 && getHour() == 16) {
expY = expT*1;
YY = year(0); MM = month(0); DD = day(0);
Month=(Math.floor((MM-0.1)/3)+1)*3; //0-11 ==> 3, 6, 9 or 12
get_expiry_date(Month, YY); //basic logic to find Rollover Thursday
if ( DD > Third_Friday && MM == Month ){ //after expiry in Mar Jun and Sept
MM = Month + 3;
get_expiry_date(MM, YY);
}
else MM = Month;
if ( MM <= 9 ) MM = "0" + MM;
if ( MM >= 13 ) { MM = "03" ; YY = YY + 1 ; }//next March, next year
debugPrintln(" "+month(0)+" "+(DD*1-1)+" "+MM+" "+Third_Friday)
exp = YY + "" + MM ;
expT = MM*1000000+Third_Friday*10000+YY*1
if (expT != expY && expY != 0 ) {
debugPrintln( month(0)+"/"+day(0)+"/"+year(0)+" "+expY+" "+expT+" "+open(0, inv("D"))+" "+close(-1, inv("D"))+" "+MM+"/"+Third_Friday)
}
}
return //expT/1+""
}

function get_expiry_date( Month, YY ) {
First_day_of_Month = new Date( YY, Month-1, 1 );//month is 0-11,
Weekday = First_day_of_Month.getDay(); //getDay() is 0 - 6, sunday = 0
//debugPrintln(Weekday*1+" "+(Month)) //ok
//debugPrintln(month(0)+" "+YY+" "+Month+" "+Weekday)
if ( 5 - Weekday >= 0 ) Third_Friday = 20 - Weekday - 9;
else Third_Friday = 21 - 9;
return Third_Friday;}

Reply With Quote

Reply



futures io > > > > Futures rollover webpage/stick thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Futures Rollover Rules jdfagan Traders Hideout 2 May 5th, 2011 01:57 AM
May I light Your Stick of Dynamite, Sir? glennw The Elite Circle 4 February 27th, 2011 08:09 PM
Europe Seems to Stick to Same Economic Strategy Quick Summary News and Current Events 0 December 30th, 2010 07:10 AM
Price marker from actual candle stick jsengxx NinjaTrader Programming 4 December 16th, 2009 12:29 PM
FF allows the THREAD STARTER to ignore posters so they can NOT post in their thread. TheRumpledOne Off-Topic 2 September 19th, 2009 01:53 AM


All times are GMT -4. The time now is 08:49 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-13 in 0.15 seconds with 19 queries on phoenix via your IP 54.160.245.121