Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi kevin. I am wondering about parameter changes in a strategy while you are holding a position. I know your a proponent of walk forward optimization and parameter selection. I am wondering how you deal with open positions especially on live strategies. If the current strategy parameters are holding a position, and you re optimize the strategy for new parameters. Do you just hold the position into the new parameters and allow the strategy to decide to exit or hold based on those new parameters? Or do you exit the position then start with a clean slate into the new optimization window?
Can you help answer these questions from other members on NexusFi?
Working on daily bars I am wondering how reliable "setexitonclose" tradestation command has been for you? i feel like its too optimal an exit especially with movements being erratic near the end of the session. I was thinking going to market in the globex session or trying to exit 5 minutes before the close of the session but both would require more complicated code. I think maybe just as a platform to test ideas, setexitonclose is fine but for real world applications its probably not going to work well. Do you have any thoughts on this?
1) SetExitOnClose can NEVER work in real time with standard daily bars, since the order would get send right when the market closes (which means the order is sent too late).
2) For Globex, the last trade time is not the close time. For example, Crude Oil trades until 5 PM every day. BUT, the settlement price is determined at 2:30 PM. Tradestation and Kinetick use the settlement price as the closing price. CQG doesn't. This could mess your strategy up.
3) Instead of SetExitOnClose, try "Sell next bar market" - it is much more realistic. But thin Globex markets at open may give you bad fills.
There are ways to get around this, but solution involve multiple charts, or 1 chart with multiple datastreams, or some other difficult code.
One thing I sometimes do is have a custom session that ends 5 (or any number of) minutes before actual market close. Then I can use SetExitOnClose, because when my session "closes" the daily bar hasn't closed. I use the exact same code on testing AND live trading on my NGEC strategies ( link here). It works great.
I have a question about incubation. I was wondering if you could do incubation by segregating the most recent 3 months of your data from the WFO process. This way you would not have to actually wait 3 months to see the results. For example i have 10 years and 3 months of data. I use 2 years as in sample, randomly selected but not including the last 3 months. I walk forward using the 1st 10 years. then after those results come in i then apply the walk forward parameters to the completely virgin last 3 months. Would this be the same as waiting the 3 months? Logically to me it seems like it since a segregated 3 months and a new 3 months are the same thing to the system. Something its never seen before. I was wondering about your thoughts on that process?
I actually did that with my Combine system. I developed it in March 2013, but only used data through December 2012. Once I was done, I then used the unseen data Jan 2013- Mar 2013 as incubation. This gave me the checks and confidence I needed to trade it in the Combine. But I still wanted to do live incubation, too, and I waited until August 2013 before going live.
The major risk here is not seeing your system trade live. If you've developed hundreds of systems then you probably have a grasp on everything, but for the newer guys, you really must see your system trade live to make sure you've not made programming mistakes that are not visible during backtests or WFO's.
EDIT: Oops I thought this was the "taking a system live" thread, otherwise I would have kept my mouth shut
I was wondering when you have a trade that you roll over to the next contract. How do you do it? its very difficult to get the same price on both sides. Do you usually just try to work orders so it gets that way? or just go on both sides at the market and take the new premium as a charge? How do you minimize the effect of contract rollover?
Great question. If you do it correctly, you don't have to pay a premium, you may have to pay 2 bid/ask spread costs instead of 1, and you'll have to pay the equivalent of 1 round turn commission. A lot of people are under the mistaken impression that they always lose or gain premium during a rollover. While this might be true for strategies such as scale trading, it does not have to be true for algorithmic systems with a simple rollover. I'll explain all of that here, with a real world example.
Let's say I have a system that trades the Euro. I use the back adjusted continuous contract to calculate all parameters for the strategy. I am currently trading the September contract, but let's say I roll to December this afternoon.
Based on the signal from my continuous contract chart, I bought the September contract at 1.3272 a few days ago. Since a few days ago, September was the front month, the continuous contract thinks I entered at 1.3272.
This system has a $625 stop loss, and a $1250 profit target. So, my stop loss is at 1.3222, and my profit target is at 1.3372. Both of those are based on the September contract, which is what was the lead contract a few days ago.
So, now a few days later, I have to roll the position into December. Let's first look at the math, and what happens to the continuous contract, and why I don't lose the premium (difference) between the two contracts when I rollover.
Right at rollover, let's say December was at 1.3303, while September was at 1.3299. This is a difference of .0004, which is what the back adjusted continuous contract needs to know.
To adjust the continuous contract to have December as the front month, you simply have to add .0004 to each price point in the existing continuous contract. So, we do this, and now have a continuous contract with December as the front month.
Now, if you have your trading strategy applied to the updated continuous contract, the strategy will think you bought at 1.3276, with a stop loss at 1.3226 and a profit target of 1.3376.
"But wait!" you say. "I didn't buy at 1.3276. I somehow got screwed!"
So, here's the math, neglecting the bid/ask spread and the commission costs, just for this example.
REAL WORLD
You bought September at 1.3272. You sold September at 1.3299. Profit = $337.50
You bought December at 1.3303. Current price is 1.3303. Profit = $0
So, in the real world, you have a closed profit of $337.50, an open profit of $0.
If your new stop loss gets hit, you will lose (1.3226-1.3303)*125000 = -962.50. Add that to the previously closed profit of $337.50, and your total loss is $625.
If your new profit target gets hit, you will gain (1.3376-1.3303)*125000 = +912.50. Add that to the previously closed profit of $337.50, and your total gain is $1,250.
STRATEGY WORLD
For the original continuous contract scenario, the continuous contract thinks I entered at 1.3272.
This system has a $625 stop loss, and a $1250 profit target. So, my stop loss is at 1.3222, and my profit target is at 1.3372.
For the new rolled over continuous contract scenario, the continuous contract thinks I entered at 1.3276.
This system has a $625 stop loss, and a $1250 profit target. So, my stop loss is at 1.3226, and my profit target is at 1.3376.
So, as you can see, the profit and loss from the real world and the strategy world is exactly the same.
Next post I'll go into details on how the rollover is accomplished.
If this is confusing to anyone, please feel free to ask questions.
Suppose you are long the Sept Euro contract at 1.3222, and it is getting to the time in mid September when you must rollover to the December contract. When you have to perform this rollover in an algorithmic strategy, how do you actually accomplish it? I usually do it one of three different ways. Each one has its advantages and disadvantages.
Method 1: Quick Roll (most expensive typically)
In this approach, you enter a sell order at the market in September Euro, and enter a buy order at the market in December Euro. Since both orders are market orders, they will be immediately executed. Using the prices above, here is the math:
Closed profit = $962.50 - $5.00 commission = $957.50
Open Profit = Long From 1.3304
Advantages: guaranteed fill, quick, easy
Disadvantages: you pay 2 bid/ask spreads, and if you are not quick with second order, market could run away from you, costing you money.
Method 2: Leg In Roll (cheapest method typically, IF done correctly)
In this approach, you enter a sell order at the market in September Euro, and try to work a buy order at the bid price in December Euro. The sell is immediately executed, and the buy is a limit order, which hopefully will get filled at the price you want. Using the prices above, here is the math:
Sell September at 1.3299 (bid price)
Buy December at 1.3303 (bid price)
Closed profit = $962.50 - $5.00 commission = $957.50
Open Profit = Long from 1.3303
Advantages: you save yourself $12.50 by getting in the December contract 1 tick better than you did with method 1.
Disadvantages: more complicated, plus you may have to chase the market up to get the December fill. You can easily lose more than 1 tick by trying to be too greedy with your limit order.
Method 3: Exchange Supported Spread Roll (cost usually between methods 1 and 2)
The exchanges have a great tool to help spreaders - a dedicated quote feed and tradable symbol for executing spread orders, which is what a rollover is. In this case, you are buying or selling the spread, not the individual legs. You get simultaneously filled on both legs at the same time. Using the prices above, here is the math:
Buy Spread at 4.5 (ask price). Note that this doesn't tell you the actual execution prices. You'll see these on your statement, and they are really irrelevant in the marked to market accounting of futures (the spread price is all that really matters). So, we will just assume some prices, keeping the spread fill price correct:
Sell Sept at 1.3329
Buy Dec at 1.3329+.00045 = 1.33035
Closed profit = $962.50 - $5.00 commission = $957.50
Open Profit = Long from 1.33035
Advantages: simple, no chance of only one leg executing, cost usually in between method 1 and 2.
Disadvantages: Some brokers don't support this. Tradestation's main platform, for example, does not allow this. You can do it manually in Tradestation 4.0 platform, but that platform is not made for algorithmic strategies. It is also easy to screw up the order, and buy the spread instead of selling it. You have to be careful. Also, don't think that just because you are trading the spread symbol, you'll only pay 1 commission. Some people think this is true, and I guess those folks don't read their statements very closely. When the brokerage does its accounting, it splits the spread into a separate buy and sell fill for each leg. When this happens, commission is charged for each. There is no free lunch, commission wise, with this method!
You can see from the above example there is $12.50 cost difference between all 3 methods, with Method #1 being the most expensive, Method #2 being the cheapest, and Method #3 in between the other two. This is not always the case, but is true in general.
So, that is how a rollover is actually accomplished. Whenever I can, I use the exchange supported spreads to do my rollovers. I can do this with systems where I enter orders manually. For my fully automated systems, I generally use method 1, even though it is the most expensive. When I use Method 2, I sometimes find myself chasing the market with my order, or worse yet, I forget about the rollover for a while, leaving me temporarily doubly exposed, until I fix it.