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

Zigzag Bollinger Band
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3237
Page 3 of 28
Author:  snailbeard [ Tue Nov 12, 2013 9:38 am ]
Post subject:  Re: Zigzag Bollinger Band

In this H1 view we can see both H4 and H1 zigzags. The swing pivots provide a method of adding trend lines which form channel boundaries. In this case the strong purple lines form channel boundaries. There are two pairs the H4 pair and the H1 pair. Both H4 and H1 channels form triangles indicating reduced volatility/consolidation prior to a continuation or change of market sentiment.

The breakout from the H1 channel could be short-lived if there is strong support or resistance nearby. Also, the proximity of the H4 channel boundaries means we do not see confirmed market bias until price has escaped the H4 channel boundaries.
Author:  snailbeard [ Tue Nov 12, 2013 11:04 am ]
Post subject:  Re: Zigzag Bollinger Band

Finally, if we return to M15 and see how price has moved since yesterday:

In this chart we see how the channel boundaries could have been used by the EA to delay trading.
Firstly, we are too close to D1 Bollinger band and a weekly pivot to enter a buy trade
and secondly we clearly have contracting price movement in a wedge channel, with the bottom channel only a few pips away from the failed trade.

The next step is to use H4 sand H1 zigzags to calculate trend lines and locate channel support/resitance levels.
Author:  snailbeard [ Tue Nov 12, 2013 1:09 pm ]
Post subject:  Re: Zigzag Bollinger Band

Monitoring spread and slippage

GBPUSD: the spread varied quite a bit yesterday morning.
Nevertheless, due to the spread watcher the EA was able bide it's time and get a favourable entry.
It was in well before the big move which came this morning :D


Note that the first attempt was at 1.60123 and despite fluctuating spread it was able to enter close to the original price:

09:15:01 : IsValidSpread(): OUT OF RANGE: dSpreadInPips > 5.20

NOTE:Price: 1.60123 initially

09:15:01 : VPO: Pair: GBPUSD, bActive: 1, Sell, Lots: 0.300, Price: 1.60123, SL: 1.60423, TP: 1.59523, MTPT: 0, TS: 2013.11.11 11:15, TE: 2013.11.11 11:30
09:15:01 : IsValidSpread(): OUT OF RANGE: dSpreadInPips > 5.20


09:29:06 : VPO : GBPUSD: NOT triggered due to time: secs passed: 845 > Limit: 840
09:30:03 : IsValidSpread(): OUT OF RANGE: dSpreadInPips > 5.20

Note: Price: Price: 1.60120

09:30:03 : Alert: GBPUSD: bZzM15PentaH4Triplet && (iZzDblTripletDir < 0)
09:30:03 : VPO: Pair: GBPUSD, bActive: 1, Sell, Lots: 0.300, Price: 1.60120, SL: 1.60420, TP: 1.59520, MTPT: 0, TS: 2013.11.11 11:30, TE: 2013.11.11 11:45
09:30:03 : IsValidSpread(): OUT OF RANGE: dSpreadInPips > 5.20

09:34:59 : OrderSendReliableMKT v4.1: Attempted SELL 0.30000000 lots @1.60123000 sl:0.00000000 tp:0.00000000
09:34:59 : open #293487 sell 0.30 GBPUSD at 1.60117 ok

SELL: Got it at 1.60117
..... 1.60123
..... -1.60117
..... 0.00006 slippage/spread :D

09:34:59 : OrderSendReliableMKT v4.1: Ticket #293487: Successful SELL order placed, details follow.
09:34:59 : #293487 2013.11.11 11:34 sell 0.30 GBPUSD 1.60117 0.00000 0.00000 1.60123 -1.26 0.00 -1.12 Magic: 104214, Instant 104214

09:34:59 : OrderModifyReliable v4.1: Attempted modify of #293487 price:1.60123000 sl:1.60419800 tp:1.59519800
09:35:00 : modify #293487 sell 0.30 GBPUSD at 1.60117 sl: 1.60420 tp: 1.59520 ok
09:35:00 : OrderModifyReliable v4.1: Ticket #293487: Modification successful, updated trade details follow.
09:35:00 : #293487 2013.11.11 11:34 sell 0.30 GBPUSD 1.60117 1.60420 1.59520 1.60123 -1.26 0.00 -1.12 Magic: 104214, Instant 104214

09:45:01 : IsValidSpread(): OUT OF RANGE: dSpreadInPips > 5.20
09:45:01 : IsValidSpread(): OUT OF RANGE: dSpreadInPips > 5.20
Author:  snailbeard [ Wed Nov 13, 2013 8:52 am ]
Post subject:  Re: Zigzag Bollinger Band

A lot of traders trade breakouts of one form or another and so I have added 3 Bollinger Band breakout entry methods:
one uses the Daily Pivot and the other two methods are a combination of M15 and H1.
No zigzag or channel information is used at this stage.

Here is how these 3 methods perform on their own over 12 months:
AUDUSD-M1-DailyPivotBreakOut-v1-12months.png
AUDUSD-M1-BbBo-midH1-M15-12months.png
AUDUSD-M1-H1ULBbM15BbBo-12months.png
The first method is a typical long term autotrader result as experienced by me when downloading and trying out many free autotraders from various forums.

The second and third methods sometimes complement each other and can be profitable if augmented with the correct daily bias.
Author:  snailbeard [ Wed Nov 13, 2013 10:28 am ]
Post subject:  Time travel still doesn't work

Time travel still doesn't work

I went back to the hourly trading filters derived for the zigzag entries and applied them to the Bollinger Band breakout entries.

The result was just a reduction in the number of entries with no overall effect on profitability.

This suggests I should concentrate more on better selection of entries rather than focusing too much on the clock.

The attachment shows the backtest report for Bollinger Band breaks with and without the retrospective zigzag trading time filter:
Author:  snailbeard [ Mon Nov 25, 2013 6:38 am ]
Post subject:  Pushing the boundaries

Pushing the boundaries

The live demo basket trading has been running for several weeks now. Trading several currencies at once in the short term has not added any benefit. It appears that a number of pairs are too correlated and trigger similar trades, so if one loses so do several others.

Backtesting does not test the effects of correlation, but the filter is already available and needs turning on.

Oanda have some interesting utilities including an up-to-date correlation matrix:
http://fxtrade.oanda.com/analysis/labs/.

I have been experimenting with different ways of reducing the drawdown.
Last week I experimented with a midnight and dawn bias calculation based on 3 H4 candles.
The dawn prediction turned out to be 70% accurate but I need 90% accuracy to avoid killing winning trades.

After that I came back to one of my favourites which is zigzag channels. However, without visual feedback it is difficult to visualise the best way to make use of the data and be sure that the implementation is faithful to the original calculations.

Here is an interesting relationship between Pivots, Bollinger Bands and Channels:
2013.11.21 18:30: GBPUSD: M15[G: -2.00,W: 90.0,dL:-103.3,dH:-13.3];H1[G:-14.00,W: 87.5,dL:-95.9,dH: -8.3];H4[G: 9.00,W:286.8,dL:-224.1,dH: 62.8];D1[G:-20.00,W:373.0,dL:-265.3,dH:107.7];
2013.11.21 18:30: Alert: (bPriceCloseToDP || bPriceCloseToWP) && bPriceAboveM15UBoll && bPriceAboveH1UBoll && bPriceAboveH4UBoll
2013.11.21 18:45: GBPUSD: M15[G: -1.00,W: 98.0,dL:-91.7,dH: 6.3];H1[G:-14.00,W: 87.5,dL:-95.9,dH: -8.3];H4[G: 9.00,W:286.8,dL:-224.1,dH: 62.8];D1[G:-20.00,W:373.0,dL:-265.3,dH:107.7];
where
G: channel slope
W: channel width
dL: price to lower band
dH: price to upper band
ignore the polarity, I need to make it consistent so that -n.n means price is outside the channel.

On Friday 22 November the channels looked as follows:
GBPUSD-H1-Price-Channel-22Nov13.png
The M15 chart:
GU-M15-multiple-channels-2013-11-22.png
And this morning we can see how pertinent this information is:
Author:  snailbeard [ Mon Nov 25, 2013 6:48 am ]
Post subject:  Re: Zigzag Bollinger Band

In this update, we can see that price has reached the bottom of the M15 channel and so will we get a bounce or a breakout?
2013.11.25 07:45: Alert: (bPriceCloseToDP || bPriceCloseToWP) && bPriceCloseToD1UBoll
2013.11.25 08:00: GBPUSD: M15[G: 3.00,W: 43.4,dL: -6.3,dH: 37.1];H1[G: 11.00,W:120.2,dL:-85.4,dH: 34.9];H4[G: 16.00,W:302.1,dL:-271.8,dH: 30.3];D1[G:-20.00,W:373.0,dL:-391.2,dH:-18.2];
2013.11.25 08:15: GBPUSD: M15[G: 3.00,W: 43.4,dL: -1.0,dH: 42.4];H1[G: 11.00,W:120.2,dL:-85.4,dH: 34.9];H4[G: 16.00,W:302.1,dL:-271.8,dH: 30.3];D1[G:-20.00,W:373.0,dL:-391.2,dH:-18.2];
2013.11.25 08:30: GBPUSD: M15[G: 3.00,W: 44.9,dL: -3.9,dH: 40.9];H1[G: 11.00,W:120.2,dL:-85.4,dH: 34.9];H4[G: 16.00,W:302.1,dL:-271.8,dH: 30.3];D1[G:-20.00,W:373.0,dL:-391.2,dH:-18.2];
Author:  snailbeard [ Mon Nov 25, 2013 1:02 pm ]
Post subject:  Learning from errors

Going back (simulated) to 22 April 2013 the EA had a 'good' trade which went bad.
A glance at H4, H1 & M15 zigzags and the Bollinger bands says it all.
Fans of Rogers and Hammerstein might have been singing:
Oh what a beautiful morning,
Oh what a beautiful day,
I've got a wonderful feeling,
Everything's going my way.
but that would not have been the case if they were relying on the EA, which made the correct choice at the wrong time.
so perhaps the following data can improve the timing:

2013.04.22 00:16:
AUDUSD:
M1[G: 0.00,W: 11.9,dL: 11.1,dH: 0.8];
M15[G: 0.00,W: 83.0,dL: 11.1,dH: 71.9];
H1[G: 0.00,W: 83.2,dL: 6.1,dH: 77.1];
H4[G: -1.00,W:267.8,dL: 26.3,dH:241.5];
D1[G: 3.00,W:336.7,dL: -5.8,dH:342.5];

From M15 to D1 we have price uncomfortably close to the edge of the lower channel boundaries.
Our prefered entry would be at least 30 pips (plus some) from the nearest boundary and price moving away from the opposite boundary.

Also the proximity to the longer term boundaries is a warning of a significant reversal. This did materialize on the following morning and most robots continue to trade with the 'trend' well after the reversal.

With reference to the chart, 'A' is the premature entry, 'B' is the bounce off the lower channel boundary, 'C' is reflection from coincident H1 mid-Bollinger and the mid-channel line.
A series of candles under sloping H1 mid-Bollinger and a confirmed break below the pivot offer a reliable short entry at least to the next channel boundary.

Had the EA held off until 'E' it would have bagged two out of the 3 partial trades.

I previously discussed the optimisation of stop losses, and so increasing the stop-loss for pull-backs like this one is not an option.

The question now is can channel data be applied generally without killing too many good trades?
Author:  snailbeard [ Tue Dec 03, 2013 6:38 am ]
Post subject:  A leap in the dark

A leap in the dark

I have not posted any news for a while because I was struggling to reduce the maximum number of consecutive losing trades. It was frustrating that some of these trades were obviously not good entries.
Most of the attempts at improvements were a leap in the dark and had the opposite result.
I finally had some success by fiddling with a range of slope filters. I have also been working on a new method of entering trades which should result in about 3 to 4 trades per week instead of one to two per week. This new method will be based on a Bollinger band reentry strategy.

Yesterday, was a day for a minor celebration as the profit factor jumped from 2.6 to 3.6 and the maximum number of consecutive losses fell to two.

The report summary:

Bars in test 372888
Ticks modelled 742574
Modelling quality n/a
Mismatched charts errors 0
Initial deposit 10000.00
Total net profit 2031.92
Gross profit 2817.46
Gross loss -785.54
Profit factor 3.59
Expected payoff 34.44
Absolute drawdown 15.00
Maximal drawdown 308.52 (2.66%)
Relative drawdown 2.73% (303.66)
Total trades 59
Short positions (won %) 29 (75.86%)
Long positions (won %) 30 (90.00%)
Profit trades (% of total) 49 (83.05%)
Loss trades (% of total) 10 (16.95%)
Largest
profit trade 129.60
loss trade -115.14
Average
profit trade 57.50
loss trade -78.55
Maximum
consecutive wins (profit in money) 11 (505.14)
consecutive losses (loss in money) 2 (-212.52)
Maximal
consecutive profit (count of wins) 746.54 (10)
consecutive loss (count of losses) -212.52 (2)
Average
consecutive wins 5
consecutive losses 1
Author:  snailbeard [ Mon Dec 16, 2013 6:04 pm ]
Post subject:  Peter Pan and The Lost Bars

Peter Pan and The Lost Bars

Seems an appropriate title during this festive season...

One of the issues with CrappyTester back-testing is that the behaviour of iHigh and iLow for the current open bar is different to the live run behaviour.

When running the autotrader live we get the expected behaviour of the highest or lowest but when back-testing we are given the 'future' highest or lowest value for the current open bar.

One way to get around this is to seach through the M1 bars which are past for the highest/lowest value.
However, if you want to know the highest or lowest for say D1 there might be an overhead for looping through all those minutes every tick.

Since I like to get results back from CrappyTester within minutes rather than hours and I have rewritten swaves of code in the past to get this speed, I do not feel comfortable with such a bodge.
Instead I groaned and cursed then got down to writing a module which I'll probably compile into a DLL with just a few external functions:

Code: Select all

void 	GHL_updateBarHighLow(); // called every tick

double getBarHigh( string symbol, int timeframe, int shift);
double getBarLow( string symbol, int timeframe, int shift);
Most of the time these just redirect to iLow and iHigh except during testing and when (backbar == 0).

Since this has to take care of all timeframes I had to be careful not to add bugs rather than provide a solution to one.
As a side effect this module tracks missing minutes and missing bars and generates a report about the highest and lowest values on several sample days

Example

Code: Select all

17:56:43 bwaGetHighLow AUDUSD,M1: loaded successfully
17:56:43 TestGenerator: spread set to 2
17:56:43 bwaGetHighLow test started
:  bRestartD1Bar && (iPreviousMonth != iCurrMonth): 2010.04.01 00:00
: bRestartD1Bar && bRestartW1Bar: 2010.04.01 00:00
: GHL_updateBarHighLow() :- test time :- 
: bRestartD1Bar: 0
: bRestartH1Bar: 0
: 
Compare Low values against actual data:-
2010.04.01 00:01:00
_M1 0.91740, iLow 0.91720
_M5 0.91740, iLow 0.91710
M15 0.91740, iLow 0.91710
M30 0.91740, iLow 0.91710
_H1 0.91740, iLow 0.91710
_H4 0.91740, iLow 0.91710
_D1 0.91740, iLow 0.91720
_W1 0.91740, iLow 0.91710
MN1 0.91740, iLow 0.91350

: 
Compare High values against actual data:-
2010.04.01 00:01:00
_M1 0.91740, iHigh 0.91720
_M5 0.91740, iHigh 0.91720
M15 0.91740, iHigh 0.91720
M30 0.91740, iHigh 0.91720
_H1 0.91740, iHigh 0.91720
_H4 0.91740, iHigh 0.91720
_D1 0.91740, iHigh 0.91720
_W1 0.91740, iHigh 0.91720
MN1 0.91740, iHigh 0.93880

: --------------------------------------------------

: bRestartD1Bar && bRestartW1Bar: 2010.04.04 21:01
17:56:43 2010.04.11 21:01  bwaGetHighLow AUDUSD,M1: bRestartD1Bar && bRestartW1Bar: 2010.04.11 21:01
: 
Compare Low values against actual data:-
2010.04.14 14:47:00
_M1 0.93490, iLow 0.93470
_M5 0.93490, iLow 0.93470
M15 0.93490, iLow 0.93470
M30 0.93440, iLow 0.93420
_H1 0.93490, iLow 0.93300
_H4 0.93320, iLow 0.93300
_D1 0.92850, iLow 0.92830
_W1 0.92270, iLow 0.92240
MN1 0.91560, iLow 0.91350

: 
Compare High values against actual data:-
2010.04.14 14:47:00
_M1 0.93490, iHigh 0.93470
_M5 0.93510, iHigh 0.93490
M15 0.93510, iHigh 0.93490
M30 0.93570, iHigh 0.93550
_H1 0.93490, iHigh 0.93550
_H4 0.93570, iHigh 0.93550
_D1 0.93570, iHigh 0.93550
_W1 0.93890, iHigh 0.93870
MN1 0.93890, iHigh 0.93880

: --------------------------------------------------

17:56:43 2010.04.18 21:01  bwaGetHighLow AUDUSD,M1: bRestartD1Bar && bRestartW1Bar: 2010.04.18 21:01
17:56:43 2010.04.25 21:01  bwaGetHighLow AUDUSD,M1: bRestartD1Bar && bRestartW1Bar: 2010.04.25 21:01
: ----------------------------------------
: StrategyTester 30 day backtest missing minutes:-
: Separate occurances: 346
: ----------------------------------------
: 
Compare Low values against actual data:-
2010.04.28 20:59:00
_M1 0.92510, iLow 0.92490
_M5 0.92510, iLow 0.92490
M15 0.92510, iLow 0.92490
M30 0.92510, iLow 0.92490
_H1 0.92510, iLow 0.92460
_H4 0.92480, iLow 0.92460
_D1 0.91590, iLow 0.91570
_W1 0.91370, iLow 0.91350
MN1 0.91370, iLow 0.91350

: 
Compare High values against actual data:-
2010.04.28 20:59:00
_M1 0.92510, iHigh 0.92490
_M5 0.92550, iHigh 0.92530
M15 0.92580, iHigh 0.92560
M30 0.92580, iHigh 0.92560
_H1 0.92510, iHigh 0.92560
_H4 0.92580, iHigh 0.92560
_D1 0.92650, iHigh 0.92630
_W1 0.93140, iHigh 0.93120
MN1 0.93890, iHigh 0.93880

: --------------------------------------------------

: ----------------------------------------------------------------
: Final Summary
: GHL_CountedDays:        24
: GHL_TotalExpectedMins: 28800
: GHL_TotalReceivedMins: 28142
: TotalLostMinutes:          658
: ----------------------------------------------------------------
: M1 bars
: Day:         1(4)  2(5)
: Expected:    1440  1260
: Received:    1404  1160
: Missing:       36   100
: 
: Day:         4(0)  5(1)  6(2)  7(3)  8(4)  9(5)
: Expected:    180  1440  1440  1440  1440  1260
: Received:    136  1378  1433  1419  1415  1252
: Missing:       44   62   7   21   25   8
: 
: Day:         11(0)  12(1)  13(2)  14(3)  15(4)  16(5)
: Expected:    180  1440  1440  1440  1440  1260
: Received:    173  1424  1419  1414  1420  1260
: Missing:       7   16   21   26   20   0
: 
: Day:         18(0)  19(1)  20(2)  21(3)  22(4)  23(5)
: Expected:    180  1440  1440  1440  1440  1260
: Received:    170  1438  1421  1429  1429  1256
: Missing:       10   2   19   11   11   4
: 
: ----------------------------------------------------------------
All times are UTC Page 3 of 28