Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

jswanson

A Statistical Method For Stop Placement

Recommended Posts

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 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 post, 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 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.

 

RandomSystemResults.png

 

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?

 

Trade Recorder Function

 

Fortunately, I created an EasyLanguage function called TradeRecorder 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 mater of cut-and-pasting our trade information into another Excel spreadsheet to analyze our results. Please read this article for a more complete description on what TradeRecorder 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 post. 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.

 

RandomEntryMAEResults.png

 

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 post.

 

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 post.

 

 

Downlaods

 

The trading system code and an excel spreadsheet used in this post is available here.

Share this post


Link to post
Share on other sites

TradeStation is great, but there are limits to what can be gleaned from the reports that a strategy test generates . . .

 

For other ideas for useful Excel trade analysis using the TradeRecorder function that JSwanson has kindly provided, have a look at 'Trading Systems that Work' by Thomas Stridsman.

 

BlueHorseshoe

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • It's in the making, baby, aaah, aaah, aaah, ah-ah-aaah, ah! (System Of A Down, 2005) https://www.traderslab.io/
    • DT Dynatrace stock, good bull flag breakout and follow through at https://stockconsultant.com/?DT
    • APPN Appian stock, nice breakout at https://stockconsultant.com/?APPN
    • ACAD Acadia Pharmaceuticals stock, big day off the 16.47 triple support area at https://stockconsultant.com/?ACAD
    • Eight Figures   …First, consider the trend.   With personal computers, though Intel and Microsoft made billions from providing the foundation…   Even greater wealth was created by software companies and businesses that used PCs to transform their operations.   During the Internet boom, while Cisco and other infrastructure providers did well…   The greatest fortunes came from companies like Amazon, Google and Facebook that built applications on top of that infrastructure.   And, finally…   When the iPhone launched, the initial winners were component makers like Qualcomm and ARM Holdings.   However, the biggest long-term beneficiaries turned out to be companies that leveraged smartphones for their business models - like Uber, Instagram, and mobile payment companies.   Now, here’s why you should be excited:   There’s one industry that’s transitioning from its infra stage to full-blown adoption.   In fact, we might see HUGE shifts in the market pointing to this within sixty days from today.   You’re probably thinking I’m about to say crypto.   While also true…   I’m not talking about crypto.   I’m talking about another industry that’s about to take off. By Chris Campbell    Profits from free accurate cryptos signals: https://www.predictmag.com/   
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.