Posts Tagged ‘Cumulative’

Trading System Thoughts: Context and Using Cumulative Tick on ES/NQ

June 21, 2010

My time is being stretched in many directions–custom projects, donor requests, beginning iPhone app development, and working on my own trading skills. This post is one focused on my recent trading thoughts.

First, an unsolicited testimonial. I’ve been part of Richard Todd’s Move the Markets Team for a while now. I find it to be incredibly valuable. If you are looking for a community of experienced traders that are serious about improvement, both of themselves and of newer members, look no further. I recommend it highly. There are a lot of free areas to start with, and if you want to go deeper, he charges a modest monthly fee for full access.

As part of a conversation I had recently with Richard, I was once again reminded about the importance of market context. As I talked about in my WWJT posts, in a trending market, almost ANY trend-following setup will work. In a choppy environment, almost ANY trend-following setup will die horribly. The specific setup DOES NOT MATTER. There is no “best” set of parameters to filter out the losers on a setup basis. The problem is not with the setup, it’s with the market context. A raincoat is not the best clothing to wear on all days, just on rainy ones. Flip flops are ideal footwear on the beach, but not for climbing Mt. Everest. You pick your clothes based on the weather context you expect to encounter. Don’t agonize over whether a blue raincoat or a yellow raincoat works best, and don’t look for the magic set of sandals that keep you warm even on a snowy day. Metaphor overload, core dump…

The most important thing is to identify when the markets are likely to trend, and then to apply a trend-following setup (buy a pullback in a trend, buy a breakout, etc.) or sit out. Conversely, identify when the markets are choppy and listless, and apply a range-bound setup or sit out. I have demolished myself in the past two Augusts by playing dummy trades (trend continuation) in a seasonally flat and choppy market. I get stuck in the trap of obsessing over the entry, target and stop parameters, so I needed this reminder to get back on track.

I believe your time is best spent practicing contextual skills rather than mining for the Holy Grail setup or magic parameters. Try these steps:

1. Become proficient in identifying chop and trends after the fact. This one should be relatively self evident. Look at the day’s chart after the close, and annotate where the trends were, and where the chop was. Continue to do this on intraday charts until you can do it instantly and effortlessly.

2. Go to live data and practice identifying whether the market is in a trend or in chop RIGHT NOW. Don’t worry about if the market is going to keep trending or keep chopping. Just correctly identify what it is currently doing. Continue until you can do it instantly and effortlessly.

3. The last step is to start to try to predict what is likely to happen next during the day. Will the trend be likely to continue? Will the range probably be broken? Many things can give clues to this including volume, time of day, support/resistance levels, tape speed, pending news announcements, and so forth. Along the way you should also gain the skill of predicting whether a trading day may be trending or choppy before the day begins, and also knowing what events and price levels would imply a change to that prediction. This one can take years of screen time to become proficient. Patience and work are needed! I have started to notice myself having the beginnings of this skill. I can only chalk it up to screen time. Watching what has worked, what has failed and what has generally happened in the past. Feeding years of price data into the most complicated neural network there is: the human brain.

Note that in all of these things, I have mentioned words such as “likely to continue” and “probably”. None of this is an exact, deterministic science! You also have to be able to think, make decisions and accept outcomes probabilistically. That means that the specific outcome of any one event does not determine whether a probabilistic decision was the right one or not! In a deterministic situation, the outcome judges the decision. Gravity always pulls you down to the earth, 100% of the time. Jumping off a cliff is always a bad idea, because you will always plunge to the bottom. In a probabilistic situation, it’s the odds up front and the information you had at decision time that say whether a decision was the right call or not. The odds will play out to a degree of “rightness” in the long run, even though you may be taking a beating in the short run. This way of thinking is very difficult for many to attain, including myself. My Outcome Simulator is one tool that can help. The excellent book Trading in the Zone: Master the Market with Confidence, Discipline and a Winning Attitude by Mark Douglas is another good resource. But unless you are hard-wired this way, and most of us aren’t I would imagine, this takes PRACTICE.

Now, I’ve been watching the cumulative tick on ES 5 minute charts. I’ve noticed a couple of things. Assuming that the context is a trending market, the cumulative tick does well at picking the trend direction and also giving an entry spot. If the cumulative tick changes from bearish to bullish, then buying the first DOWNWARD tick spike across the average of the tick lows gives a great entry point. You are basically buying the first pullback in what you hope turns out to be a new uptrend, but are using the tick to tell you when the pullback is in play instead of choosing it based on price alone. If you continue to get downward tick pressure on the next bars, that clues you in that the uptrend may be failing. Otherwise, buying should pick back up and you have a winner in very short order. This strategy would work great with a partial exit, taking some off after some number of points and trailing the rest. Here’s an example paper-trade I took in the NASDAQ-100 e-minis (NQ) today:

I bought the gap fill on a tick downspike (gray oval). The tick downspike is the entry signal, but the reason for the trade is the context: I didn’t buy the first downspike because we were still in space over the gap. The second tick downspike was the first retrace to yesterday’s high. Also, a strong opening gap = bullish tones for the morning, so that said to fade the downspike, not go short. I expected a bounce, and we got it, all the way to new highs, even! Opening gaps that clear the prior day’s highs and lows are typically strong. Gaps inside the prior day’s range are less so.

Back to the trade: Ended up “buying” 1 tick above the day’s low so far (!) I traded 2 contracts, both with a 2 point initial stop. One I “sold” after a 3 point target (first green oval) and the other I put on a 3 point trailing stop and “sold” much higher (second green oval). Net +12.5 “points”.

I’ll be posting more charts and a modified cumulative tick indicator sometime over the next week. I’ll also be working on my market context skills, because that is the only effective way to minimize your losing trades, and is the foundation to using a setup in the right way. My ultimate goal is to choose a trending setup and a chop fade setup, know when to use them, and then consistently apply them, accepting the outcomes as they happen. That should be my last hurdle to arrive at net profitability. It’s been a long, hard journey, but I think I can see the oasis from here!

Cumulative Tick Indicator with Paintbars for Think or Swim

May 5, 2010

I’m pretty happy with the cumulative tick indicator now, so I’m graduating it out of “works in progress”. I think it does fairly well identifying which side of the tape to be on, which can be a real sticky point for me. Here’s a plot from the last week or so on a 5 min chart for ES:

The indicator uses paintbars for when the cumulative tick is rising or falling, hence the red or green bars. There are a few whipsaws, but on the whole when the market is trending it picks the right direction to be in. Not a complete trading system, but maybe a useful indicator to build something with. It can have a problem with gaps when looking at a multi-day chart (like with this morning), so watch out there.

The inputs:
Period = The EMA period for averaging the highs and lows of the NYSE Tick.

EMA = The EMA period to apply to the cumulative tick line for smoothing.

Lookback = Number of bars to look back to determine if the smoothed cumulative tick line is rising or falling (rising if current value is above the value X bars ago, vice versa for falling)

UseTrend (yes/no) = This uses the trend correction that I wrote about before, or not

This one is free. You can download the release of my Cumulative Tick Indicator at “Released Thinkscript Studies” on my Google site. If it helps you bank a big trade, feel free to send some my way 🙂

Weird Cumulative Tick Plot: Distribution or Math Artifact?

April 23, 2010

Okay, this is making me scratch my head a bit. Here’s a plot of the ES with my “Messing around with Cumulative Tick” indicator on it, showing 1 hour bars since March 1:

There are two sub-panel indicators. The upper is showing a histogram of the high and low values of the NYSE Tick. There are also two lines. The green line is an EMA(20) of the high values of the Tick. The red line is an EMA(20) of the low values of the Tick. If the Tick high was above the high EMA, the Tick bar is green, else it’s gray. If the Tick low was below the low EMA, the Tick bar is red, else it’s gray. The third dashed white line is the mean of the high EMA and the low EMA.

This is graphically showing what is going on under the hood in the lower indicator, which is my cumulative tick indicator. If a Tick high is above the high EMA (showing as green), then the difference between the high and the EMA is summed. Opposite for the Tick lows. So basically the more extreme a spike in the Tick compared to the corresponding EMA, the more it will move the cumulative tick.

You can see that we’ve been in a consistent downward trend in the cumulative tick. The Tick spikes on the downside have far outweighed the spikes on the upside. Normally I would chalk that up to underlying weakness in the market, and stock distribution in the face of rising prices. But it has been persistent in the face of a strong uptrend. I noticed two things:

1. The high EMA is further from the zero axis, so the strong high Tick readings aren’t getting as much credit. The low EMA is closer to the zero axis, so the strong down Tick readings are getting maybe too much influence.

2. The mean of the high and low EMA’s is almost always above zero. The broad buying strength is showing up here, but not making its way into the cumulative tick calculation.

Back when I came up with this idea, I was assuming that the zero line would be the natural balance point for Tick readings. And in a sideways market, that’s probably true. In this bull phase, it seems to be based around +200. If the broad undercurrent is important, then I need to add it. If only the extremes are important (the rest being noise) then we could be seeing huge weakness under the market’s hood. I tend to think it’s the first, and that I need to add a trend component into the calculation.

What do you think? Is this highlighting a divergence in the markets, hidden stock distribution, or is it an artifact of the numerics of my calculation?

UPDATE: I added the value of the mean of the EMA’s into the calculation. At every bar, the upspike-downspike+mean is calculated. So a -300 net downspike will be tempered by a +200 upward mean value. Then the chart looks like this, and all is right with the world:

I updated the code in “Work in Progress” with the code I’m using for this. It’s the same indicator for both sub-plots. I just hid different plots for each one manually in the chart studies window.

Messing Around With Cumulative Tick

June 13, 2009

After a comment by Donahchoo on Twitter, I started thinking of ways of looking at cumulative values of the NYSE Tick.

As with many other topics, there has been exhaustive treatment of what the Tick is and the significance thereof. Richard at Move the Markets has a very good Tick article if you want this background info. Dr. Brett Steenbarger talks a lot about how he uses cumulative adjusted Tick; see his blog for more details on what he does with it. Building on this foundation of what the Tick is, I’ll jump right in. This is more of a thought journal of my impressions than an exhaustive treatment of an optimized indicator, so it’s a bit rough around the edges.

I’ve been thinking that the most revealing information comes when we see extremes in the value of the Tick. Many times we hear of the tick being referenced to absolute levels: above +1000 could mean heavy buying, below -1000 heavy selling. The trouble with this is that sometimes you get a spike in the Tick that is unsustainable (and you should fade it), and sometimes you get heavy, extended readings for a long time (that you should be following). But the absolute level of the Tick doesn’t really tell me which is which. Additionally, it seems that when the low of a bar of the Tick stays relatively high (such as the low of a 5 min Tick bar being at +400 and the high at +1200), that means more for strength than having both a high and a low reading in the same bar, as in both +1200 and -1200.

So to define an extreme, I decided to use a different approach. First, I apply two exponential moving averages to create bands. I plotted the EMA(20) of the highs in the Tick, and the EMA(20) of the lows. Then I wrote a script to sum the net extremes ONLY, ignoring any Tick readings happening inside the bands, using this formula:


def htick = high("$TICK");
def ltick = low("$TICK");
def avgh = expaverage(htick,20);
def avgl = expaverage(ltick,20);
def bull = if htick > avgh then htick - avgh else 0;
def bear = if ltick < avgl then ltick - avgl else 0;

rec ctick = if barnumber()==1 then 0 else if IsNaN(htick) OR IsNaN(ltick) then ctick[1] else ctick[1] + bull + bear;

That code will sum only the extreme Tick readings, as defined by our EMA bands. I like this because it forms an adaptive definition for tick extremes, and it also captures the effect of having high Tick highs and lows as I described above, and vice versa for low highs and lows.

I wrote a full indicator to test this out on a 5min chart of the last 3 days in ES. I’ve plotted the indicator below the price chart. I’ve also included a separate plot of the Tick for visualization purposes. The CumTick indicator is doing all it’s own calculations behind the scenes. There are three things going on that I’ll explain:

1. A net sum line (thin line) for the cumulative values of ctick as described in the code above.
2. A 20 period EMA of the net sum line. This is done for smoothing purposes. This line is colored according to values in it’s own past–if the EMA is above the value of the same EMA 4 periods ago, it is green, else red. This lookback is kind of like the way the Fisher transform looks back at it’s own past values, only it uses a lookback period of 1.
3. I have added a cloud, red if the EMA is below zero, and green if it is above zero.

cumtickoverview

You can see that the red/green EMA does pretty well on choosing the dominant market direction. Zooming in for some detail, I’ve annotated graphically what my code from above is doing:

cumtickdetail

I wrote a couple of strategies to run a quick backtest on this. I went long when the EMA went from red to green, and opposite for shorts. I also included an ‘exit on close’ to keep this to a daytrading strategy only. Here’s what the trades looked like:

cumtickstrategy

Only a couple of whipsaws, but the entries had some significant retracement at times. With no stop loss or profit target, just reversing according to color and going flat at the end of the day, here’s the results (in ES points) for the 3 day period:

Max trade P/L: 10.00
Total P/L 26.25
Total 41 order(s)

That’s very encouraging! I always want to do a sanity check on new ideas. If it’s not profitable in a simple test, you’re not going to mine gold by tweaking it. I would need to do more work in looking at stops and more backwards data to gain confidence in it, and work on an entry setup to see if there was a smarter way to get in. I welcome comments and any ideas anybody may have, if you’re interested. You can download my indicator file and the strategy files (look for “Cumulative Tick.zip”) in the “Work in Progress” section at my google site.