It looks like I accidentally stumbled into a scalping strategy. I posted the rules near the top of the page for those that donít care about how I developed the expert advisor.
Warning : this EA cannot possibly profit on wide spreads. Do not follow this method if your brokerís spread and execution slippage average more than 2 pips.
Scalper EA Trading Rules
Chart: EURUSD 5 minute
SMA Period: 200
Moving Average Envelope: 1.0% of the SMA
Style: Counter-trend scalper
If the price crosses and closes below the lower envelope, then buy at market.
If the price crosses and closes above the upper envelope, then sell short at market.
If the price crosses and closes above the lower envelope, then exit long at market.
If the price crosses and closes below the upper envelope, then exit short at market.
Notice that the scalper strategy uses the same envelope for entry as it does for exit. The distribution of distance around the moving average is sticky when the price extends far away from the SMA.
The screenshot from NinjaTrader shows trades entering and exiting around the lower envelope
Get the code for MetaTrader 4 or NinjaTrader
Why the strategy works
The original intent for this research sought to uncover a range trading strategy based on the price crossing the moving average. Most traders think of distance in terms of pips.
Pips are valid for general context. The problem with modeling a strategy based on pips is that the the meaning of one pipís movement changes over time.
Taking the idea to extreme lengths, the value of a pip in 1999 when the euro launched around 0.80 hardly compares with todayís price of 1.30. Keeping the discussion to percentages helps to fix the meaning of an idea like 100 pips over long periods of time.
I wanted to visualize how the price generally behaves relative to the moving average. A custom NinjaTrader indicator that my programming team wrote collects and analyzes the data in an Excel spreadsheet. Excel allows me to draw a graph of how frequently the price stretches away from the 200 period simple moving average.
The frequency of percentage distances from the SMA 200 on the EURUSD.
The slope of the curve bends as the price extends further from the moving average. As you move left to right along the horizontal axis, the slope is steep until 0.75%. A kink in the curve forms at that point. The slope of the line flattens substantially from that point onward.
A big slope implies that the price will be anywhere but here on the next bar. A flat line means that the price isnít likely to go anywhere. The distance is sticky at that level.
Scalping in a moving market doesnít make sense. Itís only when we identify the sticky price condition of 1% away from the moving average that running a scalper EA makes sense.
Scalper EA Backtest results
I developed the strategy in NinjaTrader using data from 2011. My blind period was 2012, which was data that the strategy never saw in development. It was a pure walk forward test.
Results without spread costs
Profit: $5,740 on 108 trades trading 1 standard lot per signal
Profit factor: 2.18
Percent accuracy: 83.33%
NinjaTrader backtest, M5 EURUSD for 2011 without trading costs
Results with 2 pip spread costs
Profit: $1,420 on 108 trades trading 1 standard lot per signal
Profit factor: 1.24
Percent accuracy: 65.74%
A 2 pip spread substantially weighs on the performance
The scalper EA is incredibly sensitive to two assumptions: spread and slippage. I assume that anyone following this methodology trades at a reputable broker with good execution. The backtests assume that the combined cost of both spread and average slippage is 2 pips.
If your broker does not provide execution and spreads within that 2 pip window, then do not trade this strategy. I would not expect for you to walk away a winner.
Walk forward results without spread costs
Profit: $1,960 on 34 trades trading 1 standard lot per signal
Profit factor: 4.38
Percent accuracy: 88.24%
The NinjaTrader backtest shows walk forward results from 2012 on the EURUSD M5.
What is scalping?
Scalping refers to a short term trading style. Profits are very small and occur a large percentage of the time. When losses happen, they tend to be several times larger than a typical winner.
The high number of wins attracts traders of all stripes. The idea of consistently earning profits makes trading more fun and appealing. Traders with experience, which inevitably means traders that have suffered losses, also find the high percentage win rate appealing. It makes the emotional suffering far less difficult.
The emotional component that attracts traders to scalping strategies leads to illogical business decisions. Traders place the need to win frequently above the long term need to expect a profit.
Too many scalping expert advisors tap into the high winning percentage. Most fail to present a clear and obvious reason why it makes sense to scalp.
The EURUSD typically costs $2 to trade a mini lot. Many scalpers set narrow profit targets between 1-5 pips, which are worth $1-5.
The trader spends $2 to make $1-5. If this were a normal business, that would be the end of the game. You win. The game is only limited by the number of trades placed.
Trading, unlike other businesses, frequently results in losses. Itís very possible to build an expert advisor that could win trading for free but loses when costs enter the picture.
The best example is the difference in the scalper EA backtests for 2011. The first test showed a percent accuracy of 83% without including the spread. Adding the spread to the second backtest decreased the accuracy to 65%.
Trading costs make all the difference in scalping. Many scalping strategies live and die based on their trading costs.
The accuracy dropped because all trades had to subtract the spread cost from their simulated winnings. The number of trades that flipped from profit to loss because of a 2 pip spread shows how many trades profited by the narrowest of margins. The narrower the margin of profit, the more sensitive a strategy becomes to spread costs.
Do you think that I should have considered other ideas in the strategy? Suggest some ways to improve in the comments section below.
This series eventually led to a profitable trading strategy. If youíd like to read through the journey, then I suggest reading the articles sequentially
could you give me some reference to moving average envelopes, i donít understand what exactly is 1% envelope. I would like to code this strategy and testing it by myself
A moving average envelope is a percentage of the moving average. Say that the SMA is currently 100 and youíre drawing a 1% envelope. You would draw an upper band 1% above the current SMA, which is 101. You would draw the lower band 1% below the SMA, which is 99.
Does that make sense?
Thank you Shaun,
Andrew Gee says
Your returns can become stella with money management Ė if I get time this week, I will write out this strategy in Meta Trader and add my predictive money management and send you the returns.
Iím going to post the MT4 code today.
Iím really looking forward to your money management idea. Itís amazing what you can do with intelligent risk taking.
Likewise Andrew Ė will be interesting to see the difference in the results.
Thanks for this. It backtested very well. Iím impressed. Thankyou for sharing this with your clients.
Youíre welcome! Please let me know if you use it in live trading.
Andrew Gee says
Thanks for the code, saved me some hours of work writing the Metatrader code.
I did a quick analysis, I took 6 months of the EURUSD and AUDUSD from the first half of 2012. During my backtests the spread was hovering just around 2pips.
With my Money Management predictive modeller service I wrote, it returns 17 times more than the return from a fixed 0.1 lot size.
Shaun, send me your trade results and I will put it into my predictive money management modeller, so you can see what you would have returned.
My money management uses complex calculations such as kelly formulae, z-score, etc. However, the concept is easy to understand, If it predicts positive returns then it increases the lot size significantly, if predicts storm approaching or in a storm then reduces the lot size significantly. It does this over the last 7 trades.
Very cool! Iím on my way to Kansas City to speak at a traderís summit. I wonít be able to get this back to you until I return, which will be early next week.
Thanks for sharing your research.
Are you planning on posting the undated EA with your money management improvements?
Iím pretty interested to see the impact on performance with Money Management; Im currently running this on demo with 10 pairsí, trying to work out lot sizes. Has anyone considered lot size in relation to both the pairs and the account size?
do you have a white paper or blog post describing your predictive money management? I would like to read more about the concept.
Hi Shaun, Thanks for sharing your EURUSD Scalper EA. Do you use a stop loss or just wait for the bar to close above or below the envelope level?
Also have you tested it on any other currency pairs that have tight spreads? Or does it just work on EURUSD?
The strategy does not use a hard stop loss. Instead, there is always a point where the EA will exit the market at a profit or loss at the moving average envelope.
I expect that the EA would work on most other currency pairs. Iíve run the graphs that I originally created as part of the group trading strategy. Most currency pairs exhibit similar shapes to the EURUSD. The only pair where I wouldnít expect it to work is the USDJPY.
Thanks for sharing your EA. But I canít see it anywhere here, where can I download it from ?