Open Range BreakOut with Trade Management
How difficult is it to program a day trading system using an open range break out, protective stop and a trailing stop? Let’s see. I started working on this and it got a little more detailed than I wanted so I have now split it up into two posts. Part 2 will follow very soon.
What inputs do we need? How about the number of days used in the volatility calculation? What percentage of the volatility from the open do you want to buy or sell? Should we have a different value for buys and sells? Do we want to use a volatility based protective stop or a fixed dollar? How about a trailing stop? Should we wait to get to a certain profit level before engaging the trailing stop? Should it also be based on volatility or fixed dollar amt? How much should we trail – again an amount of volatility or fixed dollar?
inputs: volCalcLen(10), orboBuyPer(.2), orboSellPer(.2), volStopPer(.7), $Stop(500), volProfThreshPer(.5), $ProfThresh(250),volTrailPer(.2),$Trail(200);
That should do it for the inputs – we can change later if necessary.
This is where I will save you some time. If we use an open range break out entry we must limit the number of entries or TradeStation will continue to execute as long as the price is above our buy level. You might ask, “That’s what we want -right?” What if we use a tight stop and we get stopped out of our first position. Do you want to buy again later in the day? What if we use a trailing stop and we get out of the market above the buy level. What will TradeStation do? It will follow your exact instructions and buy again if you don’t control the number of allowed entries. Do you want to carry the buy and sell stops overnight for execution on the open of the next day – probably not! So we not only need to control the number of entries buy we also need to control the time period we can enter a trade.
We need to determine the volatility and a good way do this is calculating the average range over the past N days. There are two ways to do this: 1) incorporate a daily chart as data2 and use a built-in function for the calculation or 2) use a for-loop and use the built-in functions HighD and LowD and just use one data feed. Both have their drawbacks. The first is you need to have a multi-data chart and the second you get a warning that you shouldn’t put a series function call inside the body of a for-loop. I have done it both ways and I prefer to deal with the warning – so far it has worked out nicely – so let’s go with a single data chart.
Building the code:
Since we are combining a volatility and fixed $ amount in our trade management, you will need to set either the vol or dollar amounts to a high value to disable them. You can use both but I am taking the smaller of the respective values.
Once A Day Calculations:
Since we will be working with five-minute bars we don’t want to do daily calculations on each bar. If we do it will slow down the process. So let’s do these calculation on the first bar of the day only.
For All of You Who Don’t Want To Wait – Beta Version Is Available Below:
In my next post, I will dissect the following code for a better understanding. Sorry I just ran out of time.