In the September 2012 issue of Futures magazine, author Neil Rosenthal began a multi-part series on system development. During the first series Neil uses MetaTrader 4 (MT4) to code a simple system and demonstrates how he uses Excel to analyze the results as the first step to building a trading system. After discovering a market edge – what I call a key concept – Neil demonstrates his process of finding an initial hard stop value for his system. I found his method similar to what I use. I thought it would be helpful if I recount his method here.
While many people focus on the specifics of a trade entry, trade exit is also vitally important. After you have discovered what you think is a solid “key concept” the next question you may wish to explore is: Where should the initial stop be placed? Within Neil’s article he calls this his ISL (initial stop loss).
The Trading System
Because we are not focusing on a specific trading system I’m going use Neil’s idea of using a random entry method. That is, upon the open of the market a virtual coin will be flipped. If the coin comes up heads, we go long. If it comes up tails, we go short. This will take the focus off the trading system and place the emphasis on the true point of this article, how to determine where to place your ISL. Indeed, this process is applicable to all system trading development.
I’m going to trade this on the Euro currency futures market and will use the 830 open (Central) as the time to open a new trade and the 1500 close (Central) to close the trade. Trades will be executed and managed on a 5-minute bar chart. Below is the TradeStation code that will act as the foundation of our trading system. If you are familiar with the steps I use to develop a trading system, you will recognize this stage of development as the “Baseline” system. This Baseline system will act as our stake-in-the-ground or reference point to compare the modified version against.
vRandomNumber = Intportion( Random(100) );
If ( vRandomNumber >= 50 ) Then buy("LE") next bar at market
Else sellshort("SE") next bar at market;
The results
The system was executed over a five-year period ending July 31, 2012. No slippage or commissions were deducted from the results. The test generated 1,269 trades. The number of short trades (625) accounted for 49% of the trades and the number of long trades (644) accounted for 51% of the trades. As expected the number of winning trades is near the 50% mark at 51%. You can see that this system actually produced a positive net profit of $27,200 with an average trade of $21.43. If we factor slippage and commissions the system would appear to be a break-even system.
We can probably improve the average profit per trade by limiting what we lose on trades that move against us. This is the purpose of having an ISL. By using an Excel spreadsheet to analyze the maximum adverse excursion (MAE) for our winning and losing trades we can help narrow down a proper value for our ISL. MAE is the amount a trade moves against us. For example, if we open a trade that immediately climbs to a profit of $100, then falls to $75 into the red before we finally close the trade at our $250 profit target, our MAE would be $75.
So we now know we wish to examine the MAE of our system, but how do we do that?
TradeRecorder
Fortunately, I created an EasyLanguage function called Trade Recorder which does exactly what we need. By placing this function within our strategy code all our required trade information is sent to an Excel formatted file on our hard drive. From there it’s just a matter of cutting-and-pasting our trade information into another Excel spreadsheet to analyze our results. Please read this article for a more complete description on what Trade Recorder can do.
Data Analysis
Now that we have all the trades in an Excel file I can take this data and cut-and-paste it into another spreadsheet called Trade Analysis, which is available at the bottom of this article. This spreadsheet is nothing fancy but will compute what we are looking for. Using the sort feature in Excel I can separate the winning and losing trades. Then I can use Excel’s built in functions to generate the mean and standard deviation of the MAE values.
Below are the values generated by Trade Analysis for our example run of our trading system.
In our example trading system we can see winning trades have a mean MAE of around 19 ticks. This suggests that a stop value smaller than this value will likely result in stopping-out of winning trades. In other words, the stop value would not be large enough. On the other hand, if we look at our losing trades we can see the mean MAE is 72 ticks. Such an extreme move against us is unlikely to produce a positive trade and we should be looking at cutting our losses. Notice how losing trades move strongly against our position while winning trades take much less “heat”. With this information we already have a ballpark idea on where to place our ISL. Furthermore, the same analysis can be done with the maximum favorable excursion (MFE) to help us locate a proper profit target to test. But more on that later.
While it may be tempting to place a stop just beyond our 19 tick mean, a more optimal number can be found by using optimization. We are not done yet on determining our ISL. However, it will have to wait for a future article.
Video
Below is a video that explains in detail on how to use the Trade Recorder function with the Trade Analysis spreadsheet. These two tools can be used to help you determine your ISL for systems you develop. Both these tools are available as a free download at the bottom of this article.
Hi Jeff,
Each time you run the code a different series of random entries will be generated. Of all the possible outcomes for this system, in terms of adverse excursions, the worst MAE can obviously be found like this:
vars:x(0),y(0);
x=o-maxlist(o-l,h-o);
if x>y then
y=x;
Why not just identify a model that describes how excursions from the open are distributed between zero and y, and then situate yourself in terms of this with your ISL?
I’m not sure how helpful using a random entry actually is here.
I might be mis-thinking this though!
What’s the endgame here? Trying to optimize where to put a stop, and then testing it out of sample?
A couple of things: according to Larry Connors, stops *hurt*. That is, assuming you have an edge, no matter how bad your loss is, given that you’re at a certain unrealized loss L, to get out at that point would be to realize that loss L, when you can let the trade ride and get out at some value x < L (assuming you have an edge). Otherwise, you're going to pay a premium for abandoning your edge. At least as far as I understand it. Basically, he advocates waiting for the trade to come back, no matter what. I'm not sure I agree with him though.
What I say though is that if your trade goes off the rails the way it does, it may mean that a model is incomplete and that there's a certain property of your trading system not being picked up by the existing indicators, which should give you a more systematic stop loss. EG if you "buy the dip", you probably need some way of identifying when a dip isn't a dip, but instead a trend reversal going against you, and get out ASAP.
Hi Ilya,
No liquid indexed market (as opposed to a single stock) has ever experienced a continuous parabolic rise or decline. This means that if you buy the dip and get caught in a reversal, the new trend that follows the reversal will also have a pullback, and that the pullback is a better place to exit.
The “Connors Model” of markets seems to be based on the simple truth that they never move in straight lines for very long.
Remember, there are other ways of controlling risk besides a hard stop. I trade a variation of the Connors approach, and I control risk by using zero leverage and through position sizing. It just means that I have to look for more opportunities to exercise the strategy in more markets.
People don’t like being told “de-leverage!”, but it can be a great way to manage risk instead of stop-losses.
BlueHorseshoe
This article was already posted back in August 2012. Jeff, are you out there or is this website on autopilot these days?
I’m still here. I do rotate past articles that I think are interesting. You would be surprised how many people don’t see them until they rotate back to the feature article.
why does your stop sign only have 6 sides?
LOL! I think because it’s a hard-stop sign, not a traffic stop sign.
Hi Jeff, great tool and idea! You write:We are not done yet on determining our ISL. However, it will have to wait for a future article. Is it available already?
I was hoping to see more from the original author so I could translate it to EasyLanguage. But I never saw a follow-up article.