Posts Tagged ‘opening range’

Adaptive Opening Range Indicator for Think or Swim

August 25, 2009

The trades I have been taking lately are dependent on defining an opening range. I’ve noticed a few things that I want to trade from:

1. There is usually a good move off the open during the first half hour. I want to trade INSIDE of this move. I won’t get the whole thing, nor do I want to at this point. I’ll be happy with 1 or 2 ES points out of it.

2. Watching a 133 tick chart (the fastest available in ToS), I’ve observed something I’m calling the Opening Balance. Basically, there’s a swing one way, a swing the other way, and then a retrace to the middle of the two. Once we get the retrace, we’ve balanced the first moves off the open, and we’re waiting to see which way the scale tips. This can take anywhere from 10 seconds to 5 minutes or more.

3. I want a few early longs and early shorts to jump in and commit on the bell. That sets up some loser fuel right there! When the next push comes, one way or the other, there’s a new loser that needs to bail out, which is what pushes price. Burning losers are the jet fuel of the markets. (I should know)

My strategy is to go in the direction that the market moves right after the opening balance is made, possibly with confirmation from the internals like the NYSE A-D line and the NYSE Tick. In the past, I’ve been using a 1min time window to define the opening range, and I’ve watched how that compares to this idea of opening balance. The problem with this is that the opening balance I’m looking for could happen in the first 1min, 5min, or any other amount of time. I got whipsawed the other day when the opening balance wasn’t complete for about 5 minutes and I used a 1min OR.

I had the idea to combine my swing points indicator with the shaded opening range indicator. This way, the opening balance can be calculated according to the two price swings instead of an arbitrarily chosen time window. The result is an adaptive opening range indicator that plots the Opening Balance as I’ve defined above:

AOR_2009-08-25-TOS_CHARTS

I am beat and dying for time right now, so instead of writing a tutorial, I will post my early beta version of the indicator as an example of how to do it for the home-gamers, and the final indicator is on my Google site for donors. Note that for either, if you put the start time as the market open, you can’t use market hours only data. The Pro version has the ability to hide or show the swing points as well as changing the lookback and lookahead for defining swing points as an input. (I like 5 back and 3 forward.)

So existing donors, go grab it on the Google site under Released Thinkscript Studies. Look for “AdaptiveOR_ProSTUDY”. Feel free to donate again if you feel this is valuable to you, but it’s not required.

If you are new and want to become a donor, send me a donation through my Paypal:

For everybody else: Thinkscript time! This code will create an adaptive opening range using the definition of highest high three bars forward and three bars back for swing highs, and vice versa for swing lows.

#Start with inputting the start time you want:

Declare fullrange;
Input StartTime = 0930;

#Next define recursive functions to hold your high and low values while waiting for the OR balance to complete:

plot ORStart = if IsNaN(secondsFromTime(StartTime)) then 1 else if secondsFromTime (StartTime) >= 0 then 1 else 0;
plot ORbar1 = if barNumber() == 1 and ORStart then 1 else if ORSTART and !ORSTART[1] then 1 else 0;

rec highs = if ORbar1 then high else if high > highs[1] then high else highs[1];
rec lows = if ORBar1 then low else if low < lows[1] then low else lows[1];

Def swinghigh = if high >= high[1] and high >= high[2] and high >= high[-1] and high > high[-2] then 1 else 0;

Def swinglow = if low <= low[1] and low <= low[2] and low <= low[-1] and low < low[-2] then 1 else 0;

plot sh = if swinghigh then high else double.nan;
plot sl = if swinglow then low else double.nan;

Rec countswinghigh = if barNumber() == 1 then 0 else if !ORStart then 0 else if ORStart AND swinghigh then countswinghigh[1] + 1 else countswinghigh[1];

Rec countswinglow = if barNumber() == 1 then 0 else if !ORStart then 0 else if ORStart AND swinglow then countswinglow[1] + 1 else countswinglow[1];

rec ORHigh = if !ORStart then double.nan else if countswinglow * countswinghigh <> 0 AND countswinglow[1] * countswinghigh[1] == 0 then highs else ORHigh[1];

rec ORLow = if !ORStart then double.nan else if countswinglow * countswinghigh <> 0 AND countswinglow[1] * countswinghigh[1] == 0 then lows else ORLow[1];

Plot ORH = if ORStart then ORHigh else double.nan;
Plot ORL = if ORSTART then ORLow else double.nan;
AddCloud(ORH, ORL);

sh.SetLineWeight(3);
sh.SetStyle(curve.POINTS);
sh.AssignValueColor(color.white);
sl.SetLineWeight(3);
sl.SetStyle(curve.POINTS);
sl.AssignValueColor(color.WHITE);

S&P E-mini Futures (ES) Trades: 7-28-09

July 28, 2009

I took two trades today off the open in ES. Here’s the chart:

2009-07-28_ES_trades

I used a 133 tick chart of ES. You can see my Shaded Opening Range Indicator on there (set from 0930 to 0931), as well as my Volatility-Based Trailing Stop. I’ve also got two exponential moving averages: one is a 5 period and the other a 20 period. But instead of using the close in the EMA calculations, I’m using the pivot point of each bar, or (H + L + C) / 3. I got the idea from John Person’s book, Candlestick and Pivot Point Trading Triggers + CD-ROM: Setups for Stock, Forex, and Futures Markets. Finally, you see a study I called PACD (Pivot-based Average Convergence Divergence). Nothing too exciting–just the MACD using hlc3 to compute the EMA’s instead of close, but I changed the inputs to match the EMA’s (5, 20, and an arbitrarily chosen 5 signal line). This is showing if the 5 EMA is above the 20 EMA or vice versa, and could be used in place of the EMA’s eventually. None of this is set in stone, and it is a bit discretionary, but it’s working for me.

The first trade was a short on a pullback inside the 1min OR. The Volatility Stop was pointing short, and the NYSE A-D ratio and Tick were down and going lower. The market was fading the A-D line, but I expected the futures to fall, and 969 was the overnight low, 2 points below my target. Soon after entry, everything switched directions, but I still waited to see if it would go my way. I was within one tick of being stopped out for a bit, and then got a push back lower. I stayed with it, but in hindsight, the Volatility Stop switched directions and the 5/20 hlc3 EMA’s had crossed over (or equivalently, the PACD went above zero). I should have bailed out there for a smaller 1 or 2 tick loss, but I stayed with the original stop and it was hit, -5 ticks. Then I went long on a bounce off the OR high, stop under the OR low. This time the internals were with me, and the PACD and Volatility Stop were as well. I set a profit target for 8 ticks, and was filled. If I had margin for multiple contracts, I could have traded two, sold one at this first target and let the other go with a trailing stop, and I could have had a point or two more, but I’m happy to stop with a net positive day at +3 ticks or 0.75 points. For my personality and where I’m at as a trader, I’d rather be net positive by a fraction every day than be up big some days and down big some others. That will change down the road as I pursue net profit over time as the primary goal, but consistency and confidence is what I want to gain right now, not bags of money. Consistency first, moneybags afterwards.

My strategy lately has been to play for smaller profits, and keep wider stop losses–the exact opposite of the 1:5 Risk:Reward home run trades I have historically tried. I never would hit my targets, and I often got stopped out. So I’m bringing the two closer together, and it’s working. I intend on watching the tape and getting out in a controlled manner (like I should have on the first trade) if things aren’t shaping up as planned. The stop loss is just in case of disaster. I also don’t get greedy and take the money when it’s there at a closer target, which is different than in my past. So far so good!