HMUZ New Contract Decision script

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

HMUZ New Contract Decision script

Postby bowlesj3 » 19 Jun 2011

I am not sure what changed but Interactive Brokers does not seem to notify me any more that the new futures contract has reached enough volume to surpass the old contract. Not only that I always found I was a day late anyway and if I tried to switch contracts mid day the back fill time is way too long. So I wrote a handy little script to help me never be late again. Here are the steps to using this script. (I have only used it once so these instructions may improve).

*Some time early in the new contract month execute this procedure:
*Follow the usual steps to get the New contract into the Quote Manager.
*The first night you do the nightly procedure give yourself extra time for the extra back fill.

Nightly Procedure:(I updated this procedure and there is a wordy explanation below)
*I am not sure actually but in TWS you may need to create a row with the new symbol.
*Copy/Paste your lowest resolution chart (in my case 10 second bars).
I will refer to this new chart as "the copy chart".
*Before you switch the copy chart to the new symbol reduce the number of bars to 1000.
This will allow it to backfill much quicker. You can increase it by 1000 each new day.
*Switch to the new symbol in the copy chart.
*You are going to leave this chart in place for a while so it is important to remove all studies.
Leaving it in place saves you some time each day.
*Apply the attached script to both charts each night (You will get a txt file for each symbol).
*So the original chart has all the studies and both charts have the HMUZ compare script.
*You will find the HMUZ compare decision script files in C:\ root
*Pull the txt documents up side by side and compare the numbers hour by hour.

When the new contract has higher volume:
*Obviously if the new contract has more volume switch over your charts and execution.
*If you are ever late again update your reminder system :-)

I was going to write a map command change to merge the data and compare automatically but I have not gotten around to it. Maybe some day.
Attachments
A_HMUZ_Decision.zip
(2.11 KiB) Downloaded 337 times
Last edited by bowlesj3 on 06 Dec 2012, edited 7 times in total.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: HMUZ New Contract Decision script

Postby bowlesj3 » 10 Sep 2011

I ran this procedure over the weekend (my second run through).

I found I had to wait 3 to 4 hours for the backfill on the new 10 second bars contract because I have a lot of bars I am keeping. Yes so you do not want to do the initial backfill of the new contract before the trading day.

I also noticed that the new futures contract symbol exceed the old symbol in ticks as of 9am on Friday morning. So I decided to leave the copy of the 10 second bar chart on the workspace to see if on Monday morning the new symbol is getting more ticks earlier in the day. If it is then I will just convert the rest of the charts to the new symbol and get rid of the extra chart.

All-in-all I like this method of deciding when to switch contracts a lot better than the old "relying on TWS rollover notice". Using this method I am switched exactly when the new contract exceeds the old contract in higher ticks count. The old way I was always dealing with at least one day of thinner 10 second bars. Having the hour by hour breakdown with the side by side comparison of this new method turned out to be better in the end. It is not cumbersome at all. Perfecting it is just a mater of scheduling efficiency and having your personal procedure instructions down pat. The process breaks down into 3 parts. 1/ the initial backfill (which takes a long time waiting for the backfill itself), 2/ the nightly comparison of the two contracts (not too much time), 3/ the final conversion of the remaining charts most likely in the morning (about 5 minutes for me).

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: HMUZ New Contract Decision script

Postby bowlesj3 » 12 Sep 2011

It turns out I was correct. I did my first compare between the contracts on Saturday for the Friday trading day (I had to change the parameter date from zero for default of today's date to the Friday date). The new contract exceeded the old contract at 9am on Friday morning suggesting I should leave the copied 10 second bar chart in place for the Monday morning test. I did that and sure enough the new contract exceeded the old contract on morning morning. So my guess is this will be that pattern every time and I will switch the remainder of the charts on Monday morning before the trading day starts since the backfill is already done and the switch-over will be fast. The other option is to assume the new contract will exceed the old contract on Monday morning and convert all the charts over the weekend ahead of Monday morning.

I plan on putting the parameter date in the printout to make it clear I need to switch the date back if I run it over a weekend.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: HMUZ New Contract Decision script

Postby bowlesj3 » 06 Dec 2011

I updated the HMUZ decision script so that it would not incorrectly bypass totaling ticks for any hours if the new contract is currently very thin.

I also updated the instructions in the first post to suggest that if the back fill is taking a long time the data range should be reduced to 10,000 bars. Last night with a setting of 30,000 bars I did not get a back fill even though I left MC running all night. I tried a 10,000 bars setting today (late afternoon time) and the back fill took almost no time at all.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: HMUZ New Contract Decision script

Postby bowlesj3 » 06 Jun 2012

For anyone using this script to decide when to switch contracts and who seems to also be finding that the new symbol in the second bars copy and past chart is taking a long time to backfill , I have notice that if you set the new symbol's data range to only 1,000 bars to start then it backfills almost immediately. After that I have been working it up in steps of 1,000 bar increases and it backfills each time quickly. For 10 second bars you need 6,000 bars for a day of data for the script. It seems to be the very first backfill that takes a very long time. I have not tried a jump directly from 1,000 bars to 6,000 bars yet.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: HMUZ New Contract Decision script

Postby bowlesj3 » 09 Jun 2012

I have updated the HMUZ futures change decision script in the zip file in the first post. For those not familiar with this script, it is used to help you decide when to switch to the new futures contract. It will now set the date to the last Friday trading date automatically if you are running it on a Saturday or Sunday. I also put the date in the end of the printout as shown below.
01 203
02 228
03 410
04 838
05 810
06 821
07 934
08 733
09 1493
10 3119
11 3669
12 2390
13 2074
14 2064
15 1573
16 2850
Date=1120608
Just to let you know, based upon the (ESM2 versus ESU2 numbers) from Friday it looks like the time to switch the E-Mini futures will be Monday Morning.

I usually check the numbers each night then leave the copy chart with the new futures in the work-space for the next morning and (if the numbers are high enough) switch the futures for all charts at that time. If the counts are not high enough I just delete the copy chart until that night and paste it in for the next comparison at night and in the morning if needed.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: HMUZ New Contract Decision script

Postby bowlesj3 » 14 Sep 2012

After using this script since I first wrote it, it seems that the best time to switch the ES E-Mini is between 9:30 and 10:05 on the morning when it appears that the new contract is getting pretty close in volume to the old contract. So if you want that precision, first check it each night then if it seems like it is close check it the next morning maybe at 8am and if it is very close then check it just after 10am when that line will appear on the report. It will be at this time you know the new one exceeds the old one. If it is not then it will be the next day most likely.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: HMUZ New Contract Decision script

Postby bowlesj3 » 06 Dec 2012

In the first post of this thread, I updated part of my procedure for deciding when to switch to the new HMUZ contract month. I extracted the updated portion below. Basically I am leaving the copy chart in the work-space after the first copy and paste operation to create it. The copy chart is the one with the new contract month. After reducing the number of bars in the copy chart and then switching it to the new contract month, I then remove all studies from it and then apply the HMUZ compare decision script. The HMUZ compare decision script is also applied to the original chart which still contains all the original studies. Leaving the copy chart in place saves having to do the copy and past operation every night and saves the time wasted waiting for the backfill. Removing the original studies from the copy chart is important to speed things up and to ensure no GV updates are incorrectly applied bu the copy chart which will mess up the original chart GV outputs. So once this copy chart is in place all you have to do is increase the bars on this chart daily from the start of 1000 bars up to whatever is required to compare the old and new contracts for the most recent overnight period required. Once you have the bars increased to the correct amount to make the final decision to switch over before your trading day you do not need to do anything except compare the charts and compare the output reports side by side to make your decision as to exactly when the new contract has more volume than the old contract (most likely early one morning).
Nightly Procedure:
*I am not sure actually but in TWS you may need to create a row with the new symbol.
*Copy/Paste your lowest resolution chart (in my case 10 second bars).
I will refer to this new chart as "the copy chart".
*Before you switch the copy chart to the new symbol reduce the number of bars to 1000.
This will allow it to backfill much quicker. You can increase it by 1000 each new day.
*Switch to the new symbol in the copy chart.
*You are going to leave this chart in place for a while so it is important to remove all studies.
Leaving it in place saves you some time each day.
*Apply the attached script to both charts each night (You will get a txt file for each symbol).
*So the original chart has all the studies and both charts have the HMUZ compare script.
*You will find the HMUZ compare decision script files in C:\ root
*Pull the txt documents up side by side and compare the numbers hour by hour.


Return to “User Contributed Studies and Indicator Library”