Let’s Build a Hedged Martingale EA


Hi all,

Steve’s done a great job on this website. I love these strategies and his clear, thorough explanations and in-depth analysis of their probabilities of success.

I’ve got some ideas for a robot to build and share. I can build it, but keen to work together on the trading concepts behind it, settings and testing.



Complete Course

A complete course for anyone using a Martingale system or planning on building their own trading strategy from scratch. It's written from a trader's perspective with explanation by example. Our strategies are used by some of the top signal providers and traders

My thinking is still immature, but I have in mind a combination of 2 strategies

1. A straight forward martingale as Steve has described in figure 1 here… https://forexop.com/martingale-trading-system-overview/

2. An anti-martingale which follows the traditional martingale in direction, but without the scale up of lot sizing.

Using the example Steve has in the martingale strategy figure 1 of chasing price down with buy orders doubling up at regular intervals, averaging down. You would typically exit on a retracement back to about the second last entry for a modest profit. All normal martingale…. however you could also chase the same price down at the same time, at the same intervals with sell orders, not doubling up. This way you accumulate profit on all the sell orders all the way down on the buys.

When the retracement exit comes you are in profit on the buys, and also on the sells because you are not doubling up on the sells you will necessarily be in profit on the sells when the buys exit if you exit early. There will be an optimal point where you have maximum profit from the buys and sells. This will depend on the grid size, lot size and retracement amount.

To explain a little more how the sells profit in the falling market. Say you simply copy the martingale buy order entry points which are averaging down, with sell orders but don’t double up lot size each time. Say you go down 5 entry levels, then your retracement brings you back to level 4 for an exit of your buys in a small profit. On the sell side you have 3 sell orders in the grid in profit, one in loss and one breakeven. Overall a solid profit on the sells because you simply sold into a falling market. By exiting all orders at the same time the buy retracement will almost always get your sells out for a profit.

My thinking is that this will be a good way to hedge the martingale risk by entering with the market direction while waiting for the retracement to get you out on the non-directional orders. Might be good to put a trail on it once you’re past breakeven?

The idea needs some maturing and some careful calculations on lot and grid sizings.

Any thoughts on this approach? Maybe I’m missing some obvious logic error of why this will fail? Would anyone like to work together to mature it?

I have some experience building martingale systems like the one here which is in profit about 80% at the time of writing after about a year. Shame about the 50% hit last week, still I’ve already taken all my original capital out so its a risk free account. Can’t complain.

Thanks Fxguy

Posted by fxguy

  1. Hi,

    I just noticed this topic and interested in discussion on martingale + hedging strategy building.
    Currently I’m developing strategy and running few tests on VPS.
    My idea:
    1.Martingale trades in direction of the trend (trend detection can be by different signals, currently using NonLagMa) Testing on H4 time frame but thinking maybe worth to go to much lower time frame.
    2.Hedge is activated when trend changes (PZswing indicator). EA do not open/close any trades after this point.
    3.Manually close of Hedge. After negative trend exhales, Hedge is closed. Usually when price are out of Bollinger Band dev2 range or momentum change (Macd). I’m working on automation this function to be able to run backtests.
    4. After manual Hedge close, Martingale trades to BE point or activates Hedge again.

    Next step in this strategy is to execute Anti Martingale (Pyramid) when price reaches BE + n points. So Martingale is used for cost averaging, increase of W/L ratio and Pyramid is used to generate profit by catching big moves. Hedging is to limit exposure and to work against inevitable martingale system crash.
    My EA is built on heavily modified Blessing3.

    Your thoughts and critique are welcome.

    • Ok I’m currently 17 from india my name’s Anand. Me and my friend are currently upto making a same setup in which will be scalping the market in the way of trend. And basically when it transitions from a buy to sell . When the price initially falls from the buying side untill it confirms selling we are thinking of using martingale at this time and hedging when it confirms selling. So we profit the sell side and exit the previous buying when there’s a pullback . But this system will always be hedging and using martingale when the trend transitions from a sell to buy or buy to sell mail me we might come up to something together

  2. Thanks FxGuy. By the way you can upload images here but you will need to use an image share service (like photobucket). Just put in the url and it should display.


  3. Hi all,

    I’ve starting working on the hedged martingale EA. I haven’t had a lot of time to spend on it. To begin I’ve built a modified basic martingale system which runs OK. I’ll use this as a basis for adding the hedging. There are the inevitable large drawdowns as I haven’t built in any protection against it and haven’t optimised the settings.

    It looks like I can’t upload images here so I’ll just give the basic stats for the year of 2011, the beginning of my test data.

    Test period: Full year 2011
    Profit: 110%
    Max drawdown: 16%
    Profit factor: 2.03
    Number of trades: 866
    Profitable trades: 64%

    Looks like great results except that when this one crashes you lose everything as it is a basic martingale without any risk management built in.

    Next I’ll start working out hedging approaches. I’m thinking of scaling in with opposite orders when the martingale is going negative, but with slightly smaller orders initially than the losing ones, then increase the relative size if it keeps going negative on the original orders. It then only needs a smaller bounce to be in profit and provides a solid hedge if price runs away or gaps. I’m thinking if I can set it up well as price moves further away in the “wrong” direction, the hedging trades will over-power the negative ones to result in a profit.

    This sounds good in theory, however the position entries, sizing and exists will have to be carefully calculated and set to ensure all outcomes are positive. I suspect the basic maths will make this inherently impossible, however I’ll work on it. If I control the exit so it all shuts down together at a specific point when a reasonable profit it reached it may work. Maybe I can set it up so there are only a few points when it can conclude a series of trades and make these profit points.

    If anyone is interested in working on this with me, don’t be shy! Two heads are better than one when brainstorming ideas.

    Thanks FxGuy

  4. Hi Peacock,

    I agree, its a classic equity curve of a martingale system, however with the ability for profits to run. The very short timeframes in the results are a problem. It is very easy to curve-fit results on a backtest to suit the data for a particular time period. I can generate million dollar returns on my robot if is optimise all the settings for a particular period of time. Outside this time period it will crash with these settings.

    I would be looking for at least a few years of back tested results, plus at least 6 – 12 months of live performance to be confident a system is worth considering. Even then, as my robot shows, you can still get major drawdowns with most martingale systems. With mine, a major drawdown occurs about once a year on average. You need a few years results to realise this happens.

    Also, very good if the live performance is the same as the backtesting. This indicates a more robust system.

    I hope this helps.


  5. Hi Peacock

    I looked at the site; interesting. It looks like a very typical martingale algorithm with the characteristic step performance. But the histories are quite short (the longest are a couple thousand trades from what I could see). The incremental profit is also quite high on these which (as I wrote about in the article) can mean the risk of collapse is higher – assuming it is a classic Martingale. With regard to the black swan events you mentioned. You don’t even need one of these to push some systems over. Depending on the leverage, just a drawdown of a few percent can be enough to tip them over.


  6. Hi FxGuy,

    Yes, it is always interpretation of the outputs that is the problem. And this is a problem with all indicators I’ve come across so far. What also complicates things, for example with Bollinger/distance from MA lines etc. is that the “trigger point” can change over time (and different conditions). So for example where at one point it may indicate a reversal in another it can be a cue for a strong breakout. My preference is to use a combination of inputs from several indicators, and avoid fixed thresholds where possible.


  7. Hi Steve and FxGuy,

    I stumbled on an EA which uses martingale. I have seen them before and have the , perhaps wrong, feeling that martingale EA’s always will break only question is “when”.

    I am a great fan of Mr Taleb’s books The Black Swan and the other fooled by randomness and perhaps a bit over cautious with all kind of systems promising 5-10% profit a month, max DD of 20% (but don’t worry, that has never happened).

    For me a DD of 20% is exactly what Mr Taleb tells in his books, it will happen someday (Black Swan) but you won’t know if you have to stop at -15% or not (fooled by randomness).

    So I was looking for some info about martingale systems and found Steve’s site (great info!) and thought “let’s ask two experts on their thoughts of this system”

    At http://www.wealthcreation.sg you can find more about the system, they some also some history files where you can see how it trades.

    I am very curious what you think of it!


  8. Hi Steve,

    I’m interested in your entry trigger of the MA15 deviation. Simple is good. To automate this would you use a set figure or a variable depending on something like a percentage of the average daily range of say the last 10 days? Do you use the cross of a level away from the MA or back towards it?

    I’ve always had problems with these types of triggers, like bollinger bands and Keltner Channels where you can’t tell if price is going to return to the MA or bust out into a new trend. I guess waiting for the crossing candle to close and the high/low to be exceeded on the next candle could be a confirmation signal.

    Any comments or thoughts?

    Thanks FxGuy

  9. I tried something similar to this before using variable multiplier sizes – that is, not sticking to the classic x2 up or down but varying the multiplier according to certain conditions. This aimed to optimize against risk levels. I have to say the results were mixed – though also it was not exactly as the system you describe above. Look forward to seeing the results if you get further on this.

Leave a Reply