Gertje: a hedged grid trader

Post Reply
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Gertje: a hedged grid trader

Post by SteveHopwood »

SERIOUS WARNING
  • Most Forex traders lose all their money.
    Using the robot posted here in trading Forex does not guarantee success.
    Trading this robot could lead to serious financial loss.
    Trading this robot without understanding its underlying trading strategies guarantees traders will lose their money.
    This is not a set-and-forget ea. There is no such thing and anyone who tells you there is, is either a liar or an idiot. This EA will need manual intervention when NoOfTrades buys and sells are open, and the only recourse from there is to manage the basket manually.
    At best, a trading robot is only 90% as good as the manual strategy it trades. At best. At worst, it can be much less effective. If the strategy is rubbish, so is the robot.
    To trade this robot, you have to understand:
    • How to use EA's.
DO NOT TRADE THIS EA ON A LIVE ACCOUNT. IT IS EXPERIMENTAL.

Ehup all

Gertje contacted me with an idea that looks like fun:
  • - open a pair of buy and sell trades
    - send a grid of pending buy and sell trades x pips apart.
    - market movement will fill the pending trades in one overwhelming direction.
    - take profit when a sufficient number of buy or sell trades have taken the basket into x cash profit.
    - rinse and repeat.
The attached EA does this. In keeping with Stealth, the pending trades are represented by dashed lines - by default, green for buy and red for sell.

US citizens
It is possible for you to trade this EA. For details, read:
Sam's post at http://www.stevehopwoodforex.com/phpBB3 ... 038#p10038
TehCount's post at http://www.stevehopwoodforex.com/phpBB3 ... 064#p10064
makeda's post at http://www.stevehopwoodforex.com/phpBB3 ... 133#p10133
swg's post at http://www.stevehopwoodforex.com/phpBB3 ... 519#p10519

Inputs
There are few inputs. The few that need explanation are:
  • -PipsBetweenTrades: the distance in pips between trades.
    - NoOfTrades: the maximum number of possible buy and sell trades. If the market seesaws outrageously, then twice this number is the maximum of trades that can be opened by the EA.
Escaping a ranging market
Taking the next buy as an example, close the basket if:

- the next buy trading line is touched
- there are RangeBoundClosureTotal / 2 sell trades open

By default, RangeBoundClosureTotal = NoOfTrades * 2, or the maximum number of grid lines. It has to be divisible by 2, so there is an idiot check that rounds up one digit should you forget.

Once there are > LookForBreakevenAfter trades open and the difference between total open buys and total open sells is 1, the bot will look to close out at breakeven.

Closing a successful basket
There are a three strategies available:
  • 1) CashProfitTarget: the profit target in dollars that the basket is aiming for.
    - CashProfitPerLot: multiplies your Lot size by this number to arrive at an adaptive CashProfitTarget. Set this to zero to disable the feature.
    2) Cash jumping stop loss. By default, G uses
    • CashProfitTarget=1000;
      CashJumpingStopLoss=50;
      JslStartsAt=100;
      • This will jump the basket stoploss by $50 once the profit reaches $100.
      Set JslStartsAt to zero to disable this feature.
    3) PipsProfitTarget: this closes the basket when the profit in pips reaches this target. Enter this in pips. The EA converts this for x digit criminals. Set to zero to disable this feature.
Trade Entry
  • 1) by Rsi trend determination (see below). Only send the initial trades if Rsi indicates a trend.
    2) by using the TMA true indi. TMA works by calculating a moving average and using ATR to calculate a channel above and below the moving average. When the price touches either upper or lower tma, the ea sends the initial trades.
    • - you do not need any version of the TMA indi on your chart or in your indi folder. G emulates TMA and draws dashed yellow lines on your chart to show the upper and lower levels.
      - customisable inputs are available for the Moving Average and Atr indicators. Play with them to your heart's content. All the Tma emulation does is provide an extreme at which to enter the market. The further away the extremes, the more likely you are to enter when the market is preparing a retrace and so you will make your profits more quickly, but will have fewer initial trades. The closer the extremes, the more initial trades you will see bt also more range-bound baskets:
      • - TmaMaTimeFrame and TmaAtrTimeFrame make the Tma emulation independent of your chart time frame. They both default to H1.
        - TmaMaShift defaults to 1, so the emulation is calculating the range using the MA of the previously closed candle on you chosen time frame. This negates the 'wriggling snake head' effect of the current MA - one of Nanningbob's many ideas.
    3) disabling both the above and going with Straight Gertge as described by G in his pm.

In a trending market, this strategy has to be a winner, as the market will gradually open more and more trades in one direction until the basket tp is hit.

Money management
This allows G to calculate your lot size and to protect you from over-trading.
  • - Lot: the lot size if you do not want auto-calculation.
    - LotsPerThousandOfBalance: lot size is calculated by rounding down the balance to bare $thousands, then multiplying this figure by LotsPerThousandOfBalance to produce a lot size that will grow with the account. Set this input to zero to disable the feature.
    - IncrementalLotMultiplier: multiplies the lot size of the most recent trade by this number. The default of 1 disables lot incrementing. This feature might need adaptation, as a badly ranging market might lead to alternate buy/sell trades opening, each of which has successively higher lot sizes. This will unbalance the basket, so we shall have to see if this is a problem.
    - MaxPairsAllowed tells G to allow no further trading if there are already this number of pairs trading on the account. The pairs do not have to belong to G; they merely have to be open trades. Set this input to zero to allow unlimited trading.
Exceptionally hseful and helpful posts
http://www.stevehopwoodforex.com/phpBB3 ... 9027#p9027
http://www.stevehopwoodforex.com/phpBB3 ... 9029#p9029
http://www.stevehopwoodforex.com/phpBB3 ... 9051#p9051

Bear in mind that when the market screams off in one direction in rocket-style, the 'pending' trades are unlikely to fill. A combination of Empty4 and criminal activities will prevent trades being sent.

RSI trend detection
I have added the usual 20 period D1 Rsi trend detection routine. Disable it by setting RsiTdPeriod to zero. If used, the bot will only send initial trades if the market is trending - the trend direction does not matter.

Note that the Rsi reading on your chart will only be correct if the EA is actively looking for new trades. If it already has trades open, or is unable to trade because the number of pairs with open trades is >= MaxPairsAllowed, then the bot does not read Rsi. This cuts down on processor use. By default, G considers the Rsi to be indicating a trend, so you will see ""Market is trending (0)" on the chart.

In conclusion
On the face of it, this is a guaranteed winner. Where is the catch? Let's see.

:D

'Just in case' scripts
G sends the buy first, then creates the buy grid, then the sell and creates the sell grid. If the buy trade-send fails for any one of the thousands of reasons that Empty4 behaves true to form, G aborts the whole process and awaits the next tick before trying again.

Once the buy is open, G will keep on hammering away at sending the sell until Empty4 finally surrenders and allows it through. Theoretically, it should be impossible to end up with only the buy trade and grid, but I have seen this happen on my demo and we need a way of overcoming this situation. This is where Gertje Sell Script comes in.

Should the sell trade fail:
  • 1) remove the EA from the chart - this is essential.
    2) drag the sell script onto the chart and wait for the sell to open and the grid appear.
    3) restart Gertje, who will take over the position as though the EA had initiated everything itself (make sure your script and EA have the same magic number).
Remember, you must remove the EA before using the script. It is still thrashing away trying to send that trade, and so will stop the script working.

The buy script should not have any use, but it does allow anyone who wants to use G as a single-direction basket trader to do so. G does not send initial trades if it detects there is an open trade in either direction, so using the script first then starting up the bot will achieve single-direction trading.

Above/below market scripts
Nicastro posted this: "Would it be possible to provide a user setting for the EA to open the grid at a preset price that is manually entered.
I am thinking of testing Gertje using R1 & S1 daily readings off Scoobs RSI and Squalou’s indicator on the manual trading thread here on the forum."

We cannot have such an input within the EA - that would cause chaos. Instead, use the appropriate 'Gertje above/below-market script' script to first create the initial-trades trigger line, then drag the EA onto the chart. Rsi and Tma are incompatible with this, so they are disabled if the EA discovers one/both of the lines on the chart.

Matters of general interest

Read this post:
http://www.forexfactory.com/showthread. ... ost4923611 Newbie traders, read this for inspiration and warning. Those of you who have suffered losses, read it for inspiration. There is a thread devoted to Sam's trading method at http://www.forexfactory.com/showthre...25#post5118825

Masterly summary of hedging: http://www.forexfactory.com/showthread. ... ost4977179

EA coding
I receive may requests to code EA's. Traders, if I code your EA for free, then I will share it here. If you want me to code your EA without sharing, then my fee is $100 payable into my paypal account. I explain why at http://www.forexfactory.com/showthread. ... ost4431794, at the bottom of the post.

Useful utilities/EA's/scripts
Matt's chart-population script at http://www.stevehopwoodforex.com/phpBB3 ... 5733#p5733. Use this every time you start a fresh platform.
MaryJane has posted a fabulous utility to allow us to resize EA input windows: http://www.forexfactory.com/showthread.php?t=299017
Multi purpose trade manager: http://www.forexfactory.com/showthread.php?t=89371
Account equity analyser: http://www.forexfactory.com/showthread. ... ost4693716 Also at http://www.forexfactory.com/showthread. ... ost4709098, which includes a template for both USD and the Euro.
Past-trades display indi by squalou; shows a graphical display of the success/failure of trades in your History tab. Breathtaking piece of work. http://www.forexfactory.com/showthread. ... ost3830610
My shell EA – the code I use to produce EA's so quickly. http://www.stevehopwoodforex.com/phpBB3 ... p?f=5&t=15
You do not have the required permissions to view the files attached to this post.
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
hiredwhip
Trader
Posts: 90
Joined: Tue Nov 15, 2011 7:36 pm
Location: Mountains, East Coast USA

Re: Gertje: a hedged grid trader

Post by hiredwhip »

Got it Steve,
This could be a lot of fun......Winding up the Fun-O-Meter as I type.....Love these things....

Have a great week

whip
A rainy day is of enormous value to both the farm and the farmer....Stay Hungry. Stay Foolish....
acostafulano
Trader
Posts: 243
Joined: Tue Dec 06, 2011 3:40 pm

Re: Gertje: a hedged grid trader

Post by acostafulano »

It'd be nice to have an option to close all trades (rinse and repeat) once the maximum trades have been opened and price started going nowhere for a while (Close for loss @ spread and transaction costs as you mentioned)
User avatar
4xPIPAHOLIC
Trader
Posts: 41
Joined: Thu Nov 24, 2011 1:27 pm
Location: Montreal, Quebec, Canada

Re: Gertje: a hedged grid trader

Post by 4xPIPAHOLIC »

Sam's trading method link not working..... :?
The hardest thing for me to learn in forex.....is to sit on my ass and do nothing....
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: Gertje: a hedged grid trader

Post by SteveHopwood »

4xPIPAHOLIC wrote:Sam's trading method link not working..... :?
Tell it to get a grip on itself and start working.

Can the rest of us have some of what you are on, please? It looks like fun.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
TehCount
Trader
Posts: 19
Joined: Wed Dec 21, 2011 6:49 pm
Location: East Coast, USA

Re: Gertje: a hedged grid trader

Post by TehCount »

NOTE: These were started with the first version of this EA. The set files may or may not work with the latest version but you can see the effective settings. Trend detection (RSI) was not used on these.

UPDATE: Both killed. Old version of EA and no longer relevant..

Image
gertje.a.set
Image
gertje.b.set
You do not have the required permissions to view the files attached to this post.
Last edited by TehCount on Fri Mar 30, 2012 6:42 pm, edited 12 times in total.
musketeer
Trader
Posts: 15
Joined: Wed Dec 14, 2011 3:05 am

Re: Gertje: a hedged grid trader

Post by musketeer »

Steve, you are really a coding machine :)
it reminds me about vipergrid
http://www.forexfactory.com/showthread.php?t=109589

off-topic: let me try to write "broker "
4x4u
Posts: 1
Joined: Mon Mar 12, 2012 1:38 pm

Re: Gertje: a hedged grid trader

Post by 4x4u »

Would you please share the Topdawg EA please..

thanks.
TehCount wrote:This should be interesting.

Image
scooby-doo

Re: Gertje: a hedged grid trader

Post by scooby-doo »

This should work really well on the first Friday of the month around 1.30pm GMT on GBPUSD.

You could probably make enough money in 2 hours to to last the whole month.

Just place the trades around 1.15pm GMT.

...Let the fun begin.

The key will be to determine how far x pips to place the trades. This is what normally kills grid trading if you get it wrong.

I would work out the avaerage volatility over 240 days, say = 160 pips / 5 = 32 pips (4 digits)

So, place your trades 32 pips apart or round it down to 30 pips.

Unemployment is coming down in USA and In my opinion the next set of results for NFP should be good for the US.

Use small lots and do the above for all USD pairs and in theory you should make a killing.

Scoobs.
xxl205
Posts: 2
Joined: Thu Dec 08, 2011 1:38 pm

Re: Gertje: a hedged grid trader

Post by xxl205 »

Hello Steve,

thanks again for another EA :)

If the grid moves in one direction, why not fill in the countertrade grid ? So if market moves back, we'd be faster ... and what about martingale, eventually in both directions rising AND falling ?

I'd have more thoughts about the grid, but I have to bring them in understandable words at first :)

Cheers, George
Post Reply

Return to “Automated trading systems”