Scalper EA

 

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

Entry rules

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.

Exit rules

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.

Scalper EA trade examples

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.

Distribution of prices from SMA 200 on EURUSD M5

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%

Scalper EA backtest, no spreads

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%

Backtest results with spread

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%

Walk forward backtest

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

Scalping almost crosses the goal line

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.

After-thoughts

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

The initial strategy idea
Selecting an appropriate time frame
A research plan
An annoying surprise in the initial backtests
An attempt at range trading
Range trading results
The moving average envelope scalper

 
The screenshot from NinjaTrader shows trades entering and exiting around the lower envelope

Share this Post

 

Tags

,

Related Posts

About the author

Shaun is a passionate and proud nerd on a wide variety of topics, most of which have absolutely nothing to do with each other. He loves math and systems, which makes him a natural fit for designing trading systems. The most random fact about him is that he speaks fluent Arabic.Shaun's hobbies are running, church and spending as much time as possible with his wife and young son.

 

33 comments on “Scalper EA

  1. vince on said:

    Hi Shaun,

    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

    Best.

  2. Shaun Overton on said:

    Hey Vince,

    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?

  3. vince on said:

    Thank you Shaun,
    yes :-)

  4. Andrew Gee on said:

    Hi Shaun,

    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.

    cheers,
    Andrew

    • Shaun Overton on said:

      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.

    • Michael on said:

      Likewise Andrew – will be interesting to see the difference in the results.

  5. Hi Shaun,
    Thanks for this. It backtested very well. I’m impressed. Thankyou for sharing this with your clients.

  6. Andrew Gee on said:

    Hi Shaun,

    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.

    cheers,
    Andrew G

    • Shaun Overton on said:

      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.

    • Jason P on said:

      Andrew

      Are you planning on posting the undated EA with your money management improvements?

      Jason

      • Michael on said:

        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?

    • Mike on said:

      Hi Andrew,

      do you have a white paper or blog post describing your predictive money management? I would like to read more about the concept.

      Thanks!

      Mike

  7. Simon on said:

    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?

    Many thanks
    Simon

    • Shaun Overton on said:

      Hey Simon,

      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.

  8. Shunmas on said:

    HI Shaun !

    Thanks for sharing your EA. But I can’t see it anywhere here, where can I download it from ?

    Thanks

  9. HI Shaun,

    Thanks for sharing. But I can’t see it anywhere here to download.
    Where can I download it from?

    Thanks.

  10. Vince on said:

    Hi Shaun,
    i know you took down the download section, i want to know if the rules you posted is enough to code the system, i’ll try to code it by myself.

    Best.

  11. Michael on said:

    Hey Andrew, am I able to obtain a copy of your predictive MM modeller within the MT4 code at all?

    Thanks

    -Michael

  12. Steven Randolf on said:

    Hi Shaun,

    You made a fine EA. I’m currently trading with 0.01 lots per 100K, and I am running the EA on a $300 real account at: http://www.forexrazor.com/en-us/account.aspx?sid=14764

    Cheers,
    Steven

  13. Buzz on said:

    hi Shaun,
    I signed up but didn’t get the free copy of the Scalper EA.
    Can u take a looksee?
    Thnx – Buzz

    • Shaun Overton on said:

      Hi Buzz,

      It can take up to an hour for the email to arrive. Please let me know if you’re still having trouble.

  14. George on said:

    I did not see the code when I clicked on the link. Did I do something wrong? Is there a specific time frame that this EA works. Like from 5am est to 10 am or something like that?

    • Shaun Overton on said:

      Hi George,

      Thanks for the comment. The EA runs 24-7. It’s not limited to certain times of day.

      The code is emailed within an hour of completing the email registration.

  15. Joe on said:

    Hi Shaun
    I did some backtesting with the EA on MT4. I have my backtesting data setup so that I get 99% quality. The EA did not perform very well at all. If you would like to see the reports, let me know where I can send them to you. I left all the inputs at default. Maybe I’m doing something wrong. Thx Joe

Leave a Reply

Your email address will not be published. Required fields are marked *

*

19,558 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>