Jul 212014
 
Mordor's gridder 18 months

Mordor’s gridder in 01 Jan 2013 – 20 Jul 2014 (18 months)

This is the first successful EA I coded while working my way out of past mistakes. It is completely working EA. Named it V 0.1 because I have more ideas to develop and I may build them upon this code later.

It is one of the ideas I came up while observing the behavior of other grid systems in the market. In short.

  1. Grid system. You open new positions every XX pips.
  2. Low (-ish) risk, with small profitability.
  3. Moderate draw-down.
  4. Non NFA compliant (Hedges)
  5. ECN compliant (no SL and TP is ever set, so it runs on ECN brokers, just fine)
  6. TP is not set, but a fixed amount of money for total profit is used.
  7. No stop loss, everything is hedged, so it’s not necessary.
  8. Works better in more volatile pairs.

—> You can download the code here. <—

Or get the results from the picture above –> Right from here.

I have used the following settings for those results:

  • AggresiveHedge=1;
  • GrabAndRunTarget=5;
  • InitialLots=0.01;
  • PipsPerStep=50;

Theory behind the EA.

In a trendy market or in market with large swings, you can run automated trader (like this one) to capture moves, regardless where they go.

You open both long and short positions and start adding up to shorts or longs depending on where the market goes.

If the market swings back against your already open positions, you add positions in the same direction as market, until the winners overwhelm the losers.

If too many positions are open in one direction and market swings back, you have the choice to wait until the EA balances it, or use aggressive mode 1 or 2 (1 = mild, 2 = worse than Martingale)

Provided you have $300-500 buffer for a bundle starting at 0.01 lots, this system is quite safe.

Here are 2 examples of how this looks like in live account:

Screenshot_2014-07-21-11-08-27 Screenshot_2014-07-21-11-08-59

If you don’t set too much profit to take, the EA usually takes the profit after opening 3 positions.

If you aim higher, you need to wait, until the EA opens enough winners to collect the targeted profit.

It is a Slow and steady EA, so you need to be patient.

PROs.

  • Set and forget. Provided you have enough buffer in the account – this system will work for you, while you sleep.
  • You can start working with $500 account.
  • Profit is guaranteed. Sooner or later.
  • Low or No risk on grid sizes >30 pips.

CONs.

  • You depend on trendy markets. If the market ranges – you can see the system locked between losers, waiting for a trend.
  • It is really slow system when locked with too many open positions. You may wait a week until it unlocks or use aggressive mode.
  • Quite high risk on grid sizes <25 pips due to more frequent lockouts.
  • I have written the code for 5-digit brokers. Will change it later, when I have more time to write 🙂

When the system goes locked badly?

It does not happen often, but you may stumble on a square formation when market is ranging, then goes wild for few quick swings and then ranges again. Like this:

Example of EA lockout.

Example of EA lockout.

When something like this happens, the EA will have 6 losers and you will need plenty of patience, until the market swings further up or down, so the EA covers the losers with winners and closes into profit.

Unfortunately, if you have a grid of 20 pips, you will need to wait for a 100-PIP swing from the EA pivot point, to cover everything.


With 3 long losers and 3 short winners, you have:

  1. Position 1 (furthest long) @ -120 PIPs.
  2. Position 2 (further long) @ -100 PIPs.
  3. Position 3 (nearest long) @ -80 PIPs.
  4. Position 4 (furthest short) @ +60 PIPs.
  5. Position 5 (closer short) @ +40 PIPs.
  6. Position 6 (closest short @ +20 PIPs.

Total losers 3, with -300 PIPs loss.

Total winners 3, with 120 PIPs profit.

To balance this, you need another short (or few shorts) which will cover all 3 losers.

Normally it will take 3+ more short winners to cover all losers (Another 60 pips move down) or one big short which will cover all losers in the next swing down.

I have coded 2 kinds of aggressive approach to this issue.

First method will open 3 x initial_lots short (in the above case). This covers most cases where the market exits from the range, but will not cover the cases where the market swings back (and opens 2 more long positions) and then returns to ranging. For this, I developed method 2.

Second method will open next position with the lot-size equal to the sum of lots on all already opened positions on the other side of the EA’s pivot.

e.g. If you have initial lots = 0.01 and turn out locked with 0.05 lots short and 0.03 lots long – next Long position opened will be with size 0.05 to cover those nasty 5 shorts opened to balance the 3 long in the example above.

If this is not right for you, feel free to change this part of the code with whatever suits you:

	orders_Total = CountOrders();
	
	if( orders_Total > 0) {
		longDelta = (currentPrice - order_maximal);
		shortDelta = (order_minimal - currentPrice);
		longPipDistance = longDelta * Normalizator;
		shortPipDistance = shortDelta * Normalizator;
		if (longPipDistance > PipsPerStep) {
			if (AggresiveHedge == 1) {lots = orders_Short * InitialLots;}
			if (AggresiveHedge == 2) {lots = lots_Short;}
			check = CreatePendingOrders(LONG, OP_BUY, Ask, lots, 0, 0, ""); 
		}
		if (shortPipDistance > PipsPerStep) {
			if (AggresiveHedge == 1) {lots = orders_Long * InitialLots;}
			if (AggresiveHedge == 2) {lots = lots_Long;}
			check = CreatePendingOrders(SHORT, OP_SELL, Bid, lots, 0, 0, "");
		}
	}

**DISCLAIMER**
This blog post is for research and entertainment purposes only. ForEx trading carries the potential for substantial gains and substantial losses. Any potential losses suffered through ForEx using the information in this blog post is unfortunate, but cannot in any way, shape or form be used against me. I cannot be held liable for any losses suffered on your part in the market.

Thank you in advance.

Happy PIPping and if you have any ideas to get this system better – drop me a line 🙂

 Posted by at 6:47 pm