stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Gertje: a hedged grid trader
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=424
Page 21 of 24
Author:  SteveHopwood [ Sat Apr 14, 2012 12:17 pm ]
Post subject:  Re: Gertje: a hedged grid trader

Be excited guys, be very excited. My bath-lol was exceptionally profitable today. :lol:

If any of you have not done so yet, go back to this post http://www.stevehopwoodforex.com/phpBB3 ... 759#p10759, read it, download the indi and drip it on a few M15 charts to see how effective it is.

My idea is this:
  • - You see the price is in a CZ.
    - The coming-soon 'Gertje plus Sq plus Forexhard' is programmed so that it draws buy stop and sell stop 30 pips on either side of the market. We adjust the lines so they align with the top and bottom of the box drawn sq's indi.
    - If the market reaches the buy line, G++ takes a buy and draws the remaining buy grid, so the trades will trigger if the market continues to breakout.
    - It moves the pending sell stop line to half the extent of the CZ box. If the market falls back that far, then the sell is sent and the sell grid drawn
This has to be semi-auto at the mo, because I never worked out how to divine the top/bottom of sq's boq in code. I will send him a pm asking him how I do this - unless some of the red-hot coders here can work this out. jb68, is your snippet an accurate representation of what sq does, leaving aside the historical stuff? I can use it if it is, and you get the credit.

More later when I have done some coding.

:D
Author:  acostafulano [ Sat Apr 14, 2012 3:27 pm ]
Post subject:  Re: Gertje: a hedged grid trader

SteveHopwood wrote:Be excited guys, be very excited. My bath-lol was exceptionally profitable today. :lol:

If any of you have not done so yet, go back to this post http://www.stevehopwoodforex.com/phpBB3 ... 759#p10759, read it, download the indi and drip it on a few M15 charts to see how effective it is.

My idea is this:
  • - You see the price is in a CZ.
    - The coming-soon 'Gertje plus Sq plus Forexhard' is programmed so that it draws buy stop and sell stop 30 pips on either side of the market. We adjust the lines so they align with the top and bottom of the box drawn sq's indi.
    - If the market reaches the buy line, G++ takes a buy and draws the remaining buy grid, so the trades will trigger if the market continues to breakout.
    - It moves the pending sell stop line to half the extent of the CZ box. If the market falls back that far, then the sell is sent and the sell grid drawn
This has to be semi-auto at the mo, because I never worked out how to divine the top/bottom of sq's boq in code. I will send him a pm asking him how I do this - unless some of the red-hot coders here can work this out. jb68, is your snippet an accurate representation of what sq does, leaving aside the historical stuff? I can use it if it is, and you get the credit.

More later when I have done some coding.

:D
Let me see if I got it right: Once price breaks out from the box, the EA only triggers the grid in the direction it went, and the opposite pending trade (and grid) is moved to be triggered only if PA goes back to the previously said box, right?

Other from that (The entry), are there going to be any other changes in the trading logic? THe EA with the current TMA entry is already working quite well, and keep in mind that by sending only one side of the grid we lose the hedging advantage inherent and necesary for this strategy to work.
Author:  jb68 [ Sat Apr 14, 2012 3:48 pm ]
Post subject:  Re: Gertje: a hedged grid trader

SteveHopwood wrote:Be excited guys, be very excited. My bath-lol was exceptionally profitable today. :lol:
This has to be semi-auto at the mo, because I never worked out how to divine the top/bottom of sq's boq in code. I will send him a pm asking him how I do this - unless some of the red-hot coders here can work this out. jb68, is your snippet an accurate representation of what sq does, leaving aside the historical stuff? I can use it if it is, and you get the credit.

More later when I have done some coding.

:D
If you drop latest version of Sq's indi in an EA you will get a zero-division error. I remember a few month ago I removed something from it.. in orer to work with an EA. I attached modified version.

Here are the buffers.. you need to call:

// Breakout Box Buffers 0, 1 -> Not null when new CZ box appear
double BB0=iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 0,1);
double BB1=iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 1,1);

// BB2, BB3 -> Value of the last UP and DW lines from the last CZ box
double BB2= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 2,1);
double BB3= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 3,1);

//BB4 - BB5 - Actual SQ signals - No null when Buy / sell signal appear
double BB4= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 4,1);
double BB5= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 5,1);


As a nice and cool thing, it will build the CZ in your window so no need to drop the indicator into the window, just the EA . Unfortunately the EA itself had marginal gains for me, but using for a grid base should be way better due to martingale effect of the grid so I hope for the best.
Author:  jb68 [ Sat Apr 14, 2012 3:59 pm ]
Post subject:  Re: Gertje: a hedged grid trader

acostafulano wrote: Let me see if I got it right: Once price breaks out from the box, the EA only triggers the grid in the direction it went, and the opposite pending trade (and grid) is moved to be triggered only if PA goes back to the previously said box, right?

Other from that (The entry), are there going to be any other changes in the trading logic? THe EA with the current TMA entry is already working quite well, and keep in mind that by sending only one side of the grid we lose the hedging advantage inherent and necesary for this strategy to work.
As somebody already said, first 2 orders in the same time are wasted money. If we put a random buy/sell EA will perform better. Grid as a math theory is a kind of martingale so the first entry is crucial.
If the first entry is right we make money if not we just struggle to not lose money.
Author:  SteveHopwood [ Sat Apr 14, 2012 4:42 pm ]
Post subject:  Re: Gertje: a hedged grid trader

jb68 wrote:
SteveHopwood wrote:Be excited guys, be very excited. My bath-lol was exceptionally profitable today. :lol:
This has to be semi-auto at the mo, because I never worked out how to divine the top/bottom of sq's boq in code. I will send him a pm asking him how I do this - unless some of the red-hot coders here can work this out. jb68, is your snippet an accurate representation of what sq does, leaving aside the historical stuff? I can use it if it is, and you get the credit.

More later when I have done some coding.

:D
If you drop latest version of Sq's indi in an EA you will get a zero-division error. I remember a few month ago I removed something from it.. in orer to work with an EA. I attached modified version.

Here are the buffers.. you need to call:

// Breakout Box Buffers 0, 1 -> Not null when new CZ box appear
double BB0=iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 0,1);
double BB1=iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 1,1);

// BB2, BB3 -> Value of the last UP and DW lines from the last CZ box
double BB2= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 2,1);
double BB3= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 3,1);

//BB4 - BB5 - Actual SQ signals - No null when Buy / sell signal appear
double BB4= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 4,1);
double BB5= iCustom(NULL,5,"sqDynamicBreakoutBox1",BoxLength,BoxTimeFrame,BoxRange,AutoBoxRange,AutoBoxRangeDailyATRperiod,AutoBoxRangeDailyATRfactor,BoxBufferPips,DaysBack,MinBarsClosedOutsideBO,MaxBreakoutTradesPerBox, 5,1);


As a nice and cool thing, it will build the CZ in your window so no need to drop the indicator into the window, just the EA . Unfortunately the EA itself had marginal gains for me, but using for a grid base should be way better due to martingale effect of the grid so I hope for the best.
Lurvely. Thanks.

:D
Author:  SteveHopwood [ Sat Apr 14, 2012 5:11 pm ]
Post subject:  Re: Gertje: a hedged grid trader

jb68 wrote:As a nice and cool thing, it will build the CZ in your window so no need to drop the indicator into the window, just the EA . Unfortunately the EA itself had marginal gains for me, but using for a grid base should be way better due to martingale effect of the grid so I hope for the best.
Yep, that is about as cool as cool gets. You should see it folks (well, you will soon); it is fantastic.

:D
Author:  jb68 [ Sat Apr 14, 2012 5:25 pm ]
Post subject:  Re: Gertje: a hedged grid trader

Steve, maybe you should add a panic / escape button

Max.Trades=25 so instead of opening # 26 to close everything.
Author:  SteveHopwood [ Sat Apr 14, 2012 6:01 pm ]
Post subject:  Re: Gertje: a hedged grid trader

jb68 wrote:Steve, maybe you should add a panic / escape button

Max.Trades=25 so instead of opening # 26 to close everything.
This is already taken care of, but if you have not followed the thread from the start then you will not know this - I need to update post 1. Also, the name of the function that manages this is a bit misleading - bool IsBasketStopLossHit(int type) Have a look at the code and you will see what I have done.

The attached is for the coders, because I am far from certain that my code is correct - and everyone here should know by now that I have a blind spot when it comes to: 1) logic; 2) custom indi's. :lol:

Here is what should happen:
  • - EA finds no trades open:
    • - calls void ReadIndicatorValues() which:
      • - uses your code to detect a CZ and draw risetoline (could have called this PendingInitialBuyStop or some such but didn't) and falltoline
From there, once a trade is triggered by the market crossing/touching one of the pending lines from within the box, the EA should
  • - draw the pending trade grid.
    - move the remaining pending trade line to half of the boxes extent.
    - manage the rest of the trading grid as normal.
I know the last lot works. It is the 'what should happen' bit that I am uncertain of.

:D
Author:  Nipponho [ Sat Apr 14, 2012 7:03 pm ]
Post subject:  Re: Gertje: a hedged grid trader

Hi,
Hope I can contribute here in my small little way.

I did a demo forward test starting 3 Apr (Asian time) market closed this week, making it ten days forward test. Pairs : EJ, EU, GBP/CHF, GBP/JPY, GU, USD/CHF & UJ. Time frame 15 min. Initial deposit is US$100k, fixed by my crim & cannot be changed. Max pairs allowed is 2.

Everything is ootb. First 2 trades of each basket, it opened 1 standard lot and subsequently onwards, it opened ten standard lots. This will be way too big for live trading. I tried to alter the extern lots per $1000, but it didn’t work. I remember seeing someone mentioned about this problem, but since it is demo, I decided to just leave the EA to its own devices and observe how it behaves.

It opened basket after basket. At one stage the drawdown was 26% (equity at about $74k). But it slowly recovered all the way to a profit of 4% ($104k equity). I had manually closed 2 baskets at loss one hour before NFP because I am afraid the spikes might distort the results. I restart the EA 2 hours after NFP.

Disregarding open trades, it now stands at $104k. 4% in 10 calendar days, not excellent, but also can’t complain too much. Maybe I had unrealistic expectation, bec the back test was sooooooo promising. However, I am mindful of the unreliability of back test.

If taking into account floating loss, equity is now 94,546, down 5.5%. I am cautiously confident it can recover since it was capable of recovering from -26% to +4%.

Closed Only/ Closed + floating
EJ +4,245.63/ +289.78
EU -15.00/ -15.00
GBP/CHF -3,216.69/ -3,216.69
GJ +898.40/ +898.40
GU +980.00/ +980.00
USD/CHF -298.25/ -298.25
UJ +2,306.11/ -3,478.50
Total before Swaps +4,900.20/ -4,840.26
Total After Swaps +4,276.62/ -5,453.84

I used the default pips between trades, but I think if we tweak it a bit, it might make a difference to its performance, but I didn’t explore this.

Sorry I am not capable of contributing on coding :oops: Comments most welcomed
Author:  Nipponho [ Sat Apr 14, 2012 7:17 pm ]
Post subject:  Re: Gertje: a hedged grid trader

I did another forward test on just AU and GU following Nubika’s settings with Lots:0.2 & pips between trades 25/27. Initial deposit $50k. Start 4 Apr & ending on Friday, about 9 days. Time frame M30
First 2 trades of basket is at 0.2 lots & thereafter 5 lots.
Closed : +$203
Closed + Floating : +$181.70
Equity now : 50181.70
Drawdown did not exceed 5%. Closed 9 baskets, one of which was closed manually to avoid NFP.
All times are UTC Page 21 of 24