Posts Tagged ‘strategy’

Just 2 NQ Points A Day

January 19, 2012

Just 2 NQ points a day. That’s all I ask. Instead of trying to get every last tick out of a given move, I am content to consistently pull out a little bit, over and over. This is the intent of the strategy.

The strategy is based on these market attributes:
1. The index futures (NQ Nasdaq emini in my case) tend to back and fill a lot. One way trends are (relatively) rare. Important price levels are revisited over and over again.
2. Market prices tend to move. Price doesn’t hold still for long.

Two points and then quit for the day should be achievable almost all the time. I just want to make chip shots. Just be consistent and do it over and over.

On a 5 min NQ chart, around half of all the bars are wider than 2 points:

20120119-231821.jpg

The average daily range for NQ lately is near 40:

20120119-231839.jpg

A two point target is in the noise. But that’s the point: Instead of trying to drink every last drop of a passing river, I want to dip my cup in and just catch a little of what is flowing by. I don’t need to catch an entire wave. Just a little portion of it.

All this time as a loser, I have been trading in hopes of catching a big move. I might have a 5 point target and a 2 point stop. I was constantly setting myself up for failure. I would enter at the market and hope for a big move, ready to take the small loss if need be. That risk:reward might look attractive, but my stop was being hit nearly every time.

So I literally faded my strategy. I looked at the current market, and placed limit orders to fade moves roughly 3 points away from the current price. That put my entry at pretty much exactly where my stop loss would have been if I traded my old way. Once one of them hit and was filled, I set a disaster stop of 5 points (basically an arbitrary number at this point), and a profit limit order just two points away from my entry. Then I sat and waited. My profit target would be hit more than 80% of the time. If the market kept going against me, I waited for it to come back. I honored the disaster stop, but in the first 18 paper trades it was never hit. Most of the time, I could get out for break-even or just a small loss close to 2 points. That exit for a small occasional loss is exactly where my trailing stop for a profit usually was under my old strategy.

To avoid fading a strongly trending market and getting my disaster stop hit, I didn’t use this method near the open or market close. I avoided fading near the highs/lows of the day. I waited for the afternoon doldrums and tried when the market was listless, choppy and noisy, putting conditions in my favor.

Another positive element in this strategy is the very short time that I am exposed to the market. In some of the engineering applications I encounter in my work, a trade-off is made between accepting risk vs. having reduced performance. A probabilistic design method is employed. Instead of designing for the worst case failure mode at the worst possible time in all conditions, we look at the probabilities that these conditions may overlap. If the worst case failure only happens at very extreme conditions, and a vehicle only spends a tiny fraction of a percent of its service life at that condition, designing for this condition puts a large burden of weight and performance reduction for the entire class of vehicle across the whole service life. We can slim down the vehicle by only designing to a probabilistically acceptable failure condition. We still have to avoid a disaster, so we make sure any failure is not catastrophic by keeping enough margin in the system. We just allow a failure to cause an aborted mission or acceptable amounts of damage. Back to my trading: most of these trades last only a few minutes or so. While big adverse moves happen in the market, the odds that one of these moves come during the few short minutes that I am exposed to the market are very small. If I’m always in the market and holding positions, then the odds are high. But the shorter my exposure time, the smaller the probability of a big event becomes. Since the probability is not zero, I still have the disaster stop, just like in the vehicle design. LTCM didn’t have a disaster stop. They KNEW that it was statistically “impossible” that they would see the conditions that would blow them up. I am not naive like that. A non-zero probability is still possible. You have to prepare against it even though you will probably rarely see it.

The biggest weakness I see is if I end up fading a persistent trend. I’ve paper traded this strategy a bit, and on a strong trend day it’s easy to rack up two 10 point losses in a hurry. That wipes out a lot of winning trades. This strategy would be best used during choppy sideways markets. How to rigorously define that is not clear to me. I guess that’s where I often get hung up. I can’t know exactly if a move will turn out to be an adverse trend every time. I have to define a way that works much of the time an accept the few times it when it doesn’t. I want to take discretionary elements out for now. The book “Trading in the Zone” is helping me to think more probabilistically rather than in “right or wrong” terms.

So the idea is literally fading my old self to have a winning strategy. I’ll be doing some back testing with it soon. If you have any comments about this
approach, I’d love to hear them.

TradeTimer for NinjaTrader 7: Control Auto-Trade Strategies by Time and Direction

November 25, 2010

I’ve just released my first commercial NinjaTrader package! It’s called “TradeTimer”, and it’s a GUI and code library that you can use with your auto-trading strategies to only trade during times of day that you specify. You can also toggle your entries on and off without stopping your strategy from processing exits and other calculations. Check it out here:

TradeTimer for NinjaTrader 7

Fade the Losers: It Begins

May 28, 2009

NOTE: I’m in process of finishing some commissioned work, as well as figuring out Ninjascript. This is an article draft I have been working on for a while, but I’m going to publish part of it now. Thanks for bearing with me during this time!

In my years of market watching, I’ve come to believe that markets are more reactive in general, not proactive. It’s not traders that proactively initiate positions that move markets, it’s traders that are reactively exiting positions that move markets. This opens up a whole new way to think about price action.

Let me qualify those statements with my personal definitions of a proactive trader vs. a reactive trader:

Proactive Trader–Has a plan or a strategy that outlines the conditions under which trading may occur; trades will not occur outside of these conditions. Waits for a piece of information, be it a price level, fundamental factor, news item, indicator or sentiment, and makes a valuation judgement based on that info; either the stock is too cheap or too expensive compared to where price should be in the future. Whether the timeframe is 10 seconds or 10 years is irrelevant–the fact is that the setup has occurred and the plan says the time is now. The trader goes to the market and trades, either entering or exiting a position. The key is that the trade is entered or exited according to an active mindset–they wilfully, intentionally CHOSE to act. I believe that proactive traders are profitable, winning traders, on average.

Reactive Trader–Has no set plan. Goes to the market looking to put on a trade, any trade, and right now. Is forced to react to price, usually by emotions and impulses, or sometimes external factors like a margin call. Jumps into a trade due to fear of missing out, usually late in the move after they see “how much money they could have made”. Does not have a pre-determined profit target, and therefore will hang on to a trade out of greed until an adverse price movement forces them out, often at a loss. Reactive traders get lucky sometimes, but they are losing traders on average.

It is true that the proactive trader is reacting to information in a way, but the proactive trader only reacts when market information matches the plans and setups that were previously defined. It is not his reactivity that defines the strategy nor the conditions under which the trade is taken though. I hope this point is clear. So the first step here is to operate from a proactive position and never from a reactive one if you want to succeed. Thankfully, human nature is what it is, and there will always be plenty of reactionary traders to transfer money into your accounts.

The markets are made up of traders. You are not trading businesses or commodities or securities as much as you are trading other traders, especially over shorter timeframes like daytrading. I believe that the majority of traders are net losers on average. Because of this, there is substantial edge in taking the other side of a loser’s trade! The money flows from weak hands to strong hands, and from reacting traders to proactive traders. I should know; I’ve been the other side plenty of times. Now I want to study the losers so I can fade them. This includes studying my past mistakes as well as observing price action in general.

So what do losers do? Losers will exit into adverse extremes, puking out their position at a point of max pain. Stops are often placed just beyond the most recent price extremes and round numbers, and savvy traders know this and position for it. Losers will enter late, after they see a big move. Losers like to enter on pauses, where the trade “lets them in”. Low volume, low speed (hint: it’s low and slow for a reason). Losers are constantly out of phase with the market waves. Losers try to pick absolute tops and bottoms, hoping to catch ALL of a move. Losers ignore market context, be it volatility, volume, support / resistance or whatever else. To a loser, “Today is a good day to trade”, all day, every day. There are a lot more, but you can see where this is going. All of these kinds of things are responsible for moving market prices! I submit that it’s the losers that actually move the market, not the winners. The winners actually dampen market movements! This is especially true intraday. An example or two should help:

Suppose a stock is trading near the highs of the day. Any trader who is short is losing. Any new short positions taken here will also become losers should prices move to a new high. Stops are placed on the other side of the day’s high by losers attempting to pick the top. There is a huge invisible sign there flashing “I am prepared to buy at these prices! Come and sell to me high!” Who is going to lift the offer here and pay up for the stock? Here’s a few people:

1. A trader / market maker with inventory purchased at a lower price who sees an opportunity to sell at higher prices. He may buy a small chunk at the market to then spin around and offer in size to the losing, stopped out traders. His catalyst buy may nudge the markets over the edge, but it’s the stops and panic of the losing shorts that applies buying pressure to the upmove. The winning trader is actually a net seller here, and is applying selling pressure that is opposed to the upmove!

2. The second person who will pay up is the reactive new long, mad that he missed the move up so far, and ready to chase a new high. He enters at a price which is usually adverse to his hoped-for trade direction, and if he is a weak hand, is about to become a loser after the shorts get done losing. On a sharp pullback, they will dump their long position, basically bailing at adverse prices because they are forced to by their stop or by their pain from the loss.

3. Longs from a higher order timeframe that are buying a breakout. A position trader from the daily or weekly timeframe is not a weak hand, and therefore will not typically be shaken out. But they also do not buy in size at a sinlge spot, so they won’t push prices much intraday.

4. Losing shorts that want to get out NOW, either by stop or by puking out their position.

You can see from these examples that losers react to price, usually adverse price movements, while winners are proactively looking for their price.

To Be Continued…

Tutorial: Trailing Stop Strategies for Think or Swim

May 14, 2009

I have received lots of requests for making a trailing stop strategy work in Think or Swim. Unfortunately, due to the way that ToS currently works with strategies, there is no way to make your entry and exit strategies “talk” to each other automatically. But it is possible to get trailing stop strategies to work! It just takes some extra elbow grease.

In general, any intelligent trailing stop must have knowledge of the entry point, so it knows where to start trailing. You can use “dumb” stops, like my experimental “N bar trailing stop” indicator, that just takes the low / high of N bars back and plots the value. This kind of a number is always on, so to speak. But if you want to trail a certain number of points behind your entry, for example, you can’t use the “dumb” stop method. You have to know where the entry took place. So how do you do it?

The way to make trailing stop strategies work is similar to the way I made my “Volatility-based trailing stop” indicator. The key is to reproduce the entry logic in your stop strategy routine. In that indicator, I had the logic for the long side and the short side together in the same set of code. This is needed for the calculation of the new stop loss value once we switch direction. Along with this, you need to define recursive functions that perform the trailing action. In the Volatility Stop, I’m actually always calculating the values of the long side stops and the short side stops according to the ATR. There is logic to check whether that value is outside the current trailed value (ignore it) or inside the current trailed value (update the trailing stop to the tighter level). This is done for both sides at the same time. There is one more set of logic to decide if we are in the long direction or the short direction, and that tells the indicator which one to plot.

Sound complicated? Actually, it’s HARDER to make the study indicator work than it is to make the strategy work! The strategy will automatically decide if you are long or short based on the criteria you give it for entries and exits. All you have to worry about is reproducing the entry logic in your exit, and the trailing logic.

Time for an example. Say you want to trail a stop N-points below your entry price, and then move it up if “low-N” is greater than the prior trailing stop value.

(Tangent–this is different than a true trailing stop like you might have with your broker, but you have to do it this way if you want to get any backtested results out of the indicator. This is because you will get falsely stopped out if your bar range is greater than your trailing N-points value if you track from the highest high, as a true trailing stop order would. If you could plot this on the tape, tick by tick, then it would work, but for any aggregated candles you have to do it this way. Here’s an explanatory picture:

TrailStopTangent

Confusing, I know; comment if you need more explanation.)

The following strategy skeleton, when fleshed out and paired with an entry strategy, will create a simple “N-points below the low” trailing stop:

declare LONG_EXIT;
# input the number of points to trail under the entry:
input trailstop=2.0;
# Reproduce Your Entry Code Below:
#################################

def trigger=if XXXXXX then 1 else 0; # check for entry condition
def orderprice=YYYYYYY; # What price? close, low, high, etc
#################################
# Now, initialize Trailing Stop
rec ts=if trigger then orderprice-trailstop else if low-trailstop>ts[1] then low-trailstop else ts[1];
# Send LONG_EXIT order if the low touches the trailing stop (ignore the entry bar):
def stopout=if trigger then 0 else if low<=ts then 1 else 0;
addorder(stopout,ts);

The part about reproducing your entry code should be self explanatory. You put the same code in that you are using for your entry. The strategy skeleton above uses two other lines:

def trigger=if XXXXXX then 1 else 0; # check for entry condition
def orderprice=YYYYYYY; # What price? close, low, high, etc

“Tigger” is the final check for your entry condition. “Orderprice” is where you put the price that you want the trade to be taken at, or the price where you would submit the order.

Now, the part with the recursive trailing logic is trickier, and is done in two parts, like this:

# Now, initialize Trailing Stop
rec ts=if trigger then orderprice-trailstop else if low-trailstop>ts[1] then low-trailstop else ts[1];

In english: If this is the entry bar then set the trailing stop N points below the order price. If it’s not the entry bar, then check if the value of low-N points > the last trailing stop value, and if it is, then that’s the new trailing stop value, but if it’s not, then keep the old one.

Then, you check if you actually get stopped out:

# Send LONG_EXIT order if the low touches the trailing stop (ignore the entry bar):
def stopout=if trigger then 0 else if low<=ts then 1 else 0;

In english: If this is the entry bar, then do nothing. If it’s not the entry bar, then if the low of the bar hit the trailing stop (or went below) then stop out, but if not, then do nothing.

The final step is in the code that actually adds the order:

addorder(stopout,ts);

In english: Add the order if we got a stop out. Use the value of the trailing stop as the order execution price.

This acts like we had an actual stop loss order in the market, and if it was hit we’d get out of the trade. So to wrap it all up, here’s an example set of files I made using a simple EMA Crossover as the entry condition. There are two studies for visualization, and two strategies–one for the entry and one for the exit:

Download Example Files

If you add all of this to a chart, it looks something like this:

TrailingStopExample51309

Trailing Stop Strategy in Think or Swim. Q.E.D.

You could reverse all of this logic to get the short side strategies as well. Now you should know enough to make your own trailing stop strategies. Unfortunately, I can’t create a standalone trailing stop strategy that you can just drop on a chart. There has to be some editing and coding done each time that you want to use a trailing stop with different strategy of your own. Feel free to ask questions if you need a pointer or two while making your own, I’m glad to help out!

Alternatively, if you would like me to do the work for you and create a custom trailing stop strategy to go along with an entry strategy you already have, contact me and I’ll code it for you for a flat $20 donation. You can choose any trailing style you like–trail N-points, ATR/volatility-based, percentage-based, etc. I do have to ask for new donations even from past donors for this specific offering due to the additional time I have to put in for each request, rather than just giving access to the products of my brain, as it were. The $20 pricing is good if you already have the entry strategy file to send me. If you need the entry strategy developed too, then it becomes a custom development request, and I’ll have to give you a quote on the number of hours it will take in order to determine the pricing. Either way, if you need some work done, send me an email.

Thinkscript Strategy Report Tool

April 14, 2009

UPDATE 12-18-2009: I updated the tool to v2 after a TOS update broke it. Get the new version at the link below!

UPDATE 4-24-2009: I updated the Thinkscript Strategy Report file to make it backward compatible with at least Excel 2000. Download again if you have had problems!

In my earlier post, I covered how to create strategies using Thinkscript. I have developed a tool that can calculate some more useful statistics about your trading system results.

After adding a strategy set to a chart, you right-click on one of the signals and choose “show report”, as described in my tutorial. Think Desktop then gives you a report on your strategy results. You can save the summary as a .csv file. The information given in the report is net Profit/Loss and the trade that gave the maximum profit. This info isn’t really adequate to evaluate a trade strategy, at least in my book.

However, since most of the information is there, all it takes is a little Excel macro magic to import the .csv file and calculate important parameters, like win rate, loss rate, average win size, average loss size, largest win streak, largest loss streak, and system expectancy, or expected profit per trade over a very large number of samples.

Once you have this information, you can plug it into my Monte Carlo Trade System Simulator and stress test it. You can see how bad (or good) your results could be in the future if all of these parameters remain constant. Or, you can adjust them and get what-if scenarios. What if I have 10% fewer winners? What if my average profit is less than what I get in this small backtest?

Well, download the Thinkscript Strategy Report tool under Released Tools at my Google site to get started! As always, you have to enable macros for the tool to work.

This release is grovel-ware:
Pleasepleasepleeeeeeeeeaze !!! Oh, please!! I will always honor your memory! I swear!!

Please note: this tool only works if you use single position strategies! If you allow more than one entry per direction in the “Properties for all” preference screen, this tool will not work.