Zigzag Bollinger Band

User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Relocation, Relocation

Post by snailbeard »

Perhaps it was unwise to dive into the stop-loss spaghetti, as it was difficult to follow the plot and it turned out to be quite hard separating out the many facets of stop-losses. The difficulty is that different entry methods require different amounts of slack. When prices are really moving its good to have a take profit distance 2 to 3 times the stop-loss distance, but on slow days the reversals can be as big as the target.
As well as dynamic ATR based variations there are boundaries (minimum and maximum stop-loss) for different entry methods and finally I need manual overrides for these boundaries as well (Russian Dolls).

After observing that too many good entries get blocked I decided to have another round of adjustments to the filters so now we have a new set of trades, some the same as before, quite a few lost and plenty waiting to be discovered/recovered.

On this H4 chart below, the general direction is clear and there should be chances to enter sell trades on each of these days: 02, 03, and 04 September 2014. However, due to some excessive filtering only the one on the third was getting through. Sometimes its it not just one filter but several:

Code: Select all

15:00 GBPUSD: :  * CAUTION * possible bW1W2FiboTrap
15:00 GBPUSD: :  PBRE Sell entry dropped (bW1W2FiboTrap && (iH4Doji) && (dH4Shrinkage < 0.2))
15:00 GBPUSD: :  PBRE  Sell entry dropped because  bTooFarFromH4Ema10
15:00 GBPUSD: :  PBRE b7D1SwingBeyondWpRange   Dir:  -1
15:00 GBPUSD: :  PBRE entry dropped because (bWpRangeDone || bDpRangeDone)
[/size]

However, the H4 chart shows 3 great trading days (except the 3rd has more reversals than the other two):
gbpusd-H4-3-possible-sell-entries-02-04-Sep2014.png
The two small H4 Doji candles are due to price being trapped between two significant Fibonacci levels a common place for a reversal but in this case price breaks-out in the same direction.

'bTooFarFromH4Ema10' was out of date and no longer true.

'b7D1SwingBeyondWpRange' means price has moved a weeks worth of pips which means avoid longer trades.

A closer look at the 4th on M15 shows several good places to enter a trade:
My preferred time is after the price movement picks up at the close of the 14:45 bar which is bigger than the previous bars and closes below a pivot level and a Bollinger band (D1 Lower). There will often be a bounce off the outer D1 Bollingers but there is still strength in the dollar and price is still moving:
gbpusd-m15-additional-entry-1400-04Sep2014.png
After reworking the filters there is an earlier entry at a break-out of two coincident (M15 & H1) lower Bollinger bands and the M15 bar is slightly bigger than previous bars - a good entry although not as strong as the close of 14:45.

Volatility hasn't picked up enough to use the longer range PBRE so ZB4 enters a shorter range PACL trade:

Code: Select all

4	2014.09.04 14:02	sell	2	0.56	1.64472	0.00000	0.00000	0.00	10096.92
5	2014.09.04 14:02	modify	2	0.56	1.64472	1.64651	1.64295	0.00	10096.92
6	2014.09.04 14:54	t/p	2	0.56	1.64295	1.64651	1.64295	95.80 	10192.72
[/size]

The good thing about the PACL entries is they can be over very quickly in this case we get our quota of pips in less than an hour. There is also a chance of another short trade later in the day but once price goes beyond DS3 we could be pushing our luck.

I am now thinking about the possibility of a trade on 2nd Sept, this was clearly a good trading day, but the difficulty for ZB4 is that price has been moving up for about two weeks. Although, the longer term price has been falling, it takes time to establish that the reversal back into the H4 Bollinger is going to continue downwards.

By grep-ing the log file we see that ZB4 acknowledges a change in the direction of price movement towards the middle of the day:

Code: Select all

:94: GBPUSD_245_02092014.txt:1135: 11:30 GBPUSD: :  PBRE iDailyDirection:  1
:96: GBPUSD_245_02092014.txt:1142: 11:45 GBPUSD: :  PBRE iDailyDirection:  1
:98: GBPUSD_245_02092014.txt:1153: 12:00 GBPUSD: :  PBRE iDailyDirection:  -1
:100: GBPUSD_245_02092014.txt:1159: 12:15 GBPUSD: :  PBRE iDailyDirection:  -1
[/size]

However, I added some safety features to prevent erratic entries near reversals:

Code: Select all

16:30 GBPUSD: :  PBRE Y1Y2 bDailyDontSell:
16:30 GBPUSD: :  PBRE NONTRADINGDAY: conflicting swings
[/size]

This does not have to be set in concrete but perhaps there is low hanging fruit elsewhere...
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

GBPUSD Low hanging fruit

Post by snailbeard »

ZB4 picked up two good trades on the 17th and 19th September but did it miss out in between on the 18th?
According the H4 chart there was a pull back followed by price moving up again on the 18th:
GBPUSD-H4-missing-buy-trade-2014-09-18.png
In the log file there are a high number of 'Buy entry dropped because bPaxStalledAtPivot'
which means price has moved up to pivot and then stalled. When price stalls under a pivot it is often a precursor to a reversal but there also many occasions when the pivots are too close together so that ZB4 never finds a good entry point.

This M15 chart shows the issue more clearly:
GBPUSD-M15-price-action-stalled-at-pivot-2014-09-18.png
This has been on my ToDo list for a while and now is probably a good time to improve this filter...
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

10% profit in a day

Post by snailbeard »

It's a most unusual day
Feel like throwing my money away
...

I was in the middle of changing ZB4 to allow it to run in user-mode, which means turning off the other entry methods and allowing me to setup a trade through the 'extern' declarations. Perhaps I should have done this a long time ago as it opens-up lots of possibilities. In short, if I think a pair is going in a particular direction and want to enter if the price crosses a threshold then these changes will help.

However, there is a secondary objective which is to be able to read and write trade setups from a file and pull them into ZB4, so that any instance of ZB4 could work as a trade copier for either another ZB4 or a separate program. It also allows forcing a particular trade setup for back-testing.

The initial intention was just to allow a single trade at a time but something interesting happened as a result of a bug. ZB4 reentered the same trade every 15 minutes for the rest of the day. I have toyed with stacking before but it is incompatible with the current profit-tracking which can only track one trade-per-pair at a time without quite a bit of extra work.

However, since it made over 10% in one day I thought it was worth doing some extra work. The next step would be to constrain the stacked entries so that they are conditional on the running profit being sufficient to cover part or all of the later entries potential losses. So this would only be worth doing when the swing is strong enough otherwise it would quickly unravel.

I might do a bit more work on this later, the way it works at the moment could easily lose just as much!

The principal settings for a manual entry are as follows:

Code: Select all

extern bool useEnterByPrice = true; // User specified entry
extern string ERP_DateAsText = ""; // if != "" then only enter on or after given time and on the same day
extern bool EPB_Buy = false; // EnterByPrice
extern bool EPB_Sell = false; // EnterByPrice 
extern double EBP_LotSize = 0.0;
extern double EBP_TriggerPrice = 0.0; // EnterByPrice threshold
extern double EBP_HiddenTargetPrice = 0.0; // Enter by price Take Profit
extern double EBP_HiddenStopPrice = 0.0; // Enter by price Stoploss

extern double EBP_NewTargetPrice = 0.0; // If >0 then update target
extern double EBP_NewStopPrice = 0.0; // If >0 then update stop
[/size]

In case the broker is deliberately manipulating the price the internal target and stop-loss are kept inside the program, although who knows if brokers can access the values of 'extern's so perhaps this is not private enough? I wonder if any of this forum's traders know the answer to that. A broker would not normally be interested to see these values unless they lose money each time the retail trader makes a profit then they might be more interested to find out as much as possible about the trader so that they can make his trades fail. Fortunately, there are a small number (but a growing number) of brokers who can make money without cheating their customers.

Code: Select all

extern string InfoCrash = "Set hard limits in case of program or system failure";
extern double EBP_DeflHardTPExtraPips = 5.0; // Add nn pips to soft target
extern double EBP_DeflHardSLExtraPips = 10.0; // add nn pips to soft stoploss
// Derive these values automatically or set them by hand:
extern double EBP_CrashTargetPrice = 0.0;  // e.g 50 pips
extern double EBP_CrashStopPrice = 0.0;	// e.g. 50 pips
// Very experimental...
extern bool EBP_AllowStacking = true; // keep entering the swing
extern int EBP_MaxStacking = 10; // limit the maximum number of trades
[/size]

In the following log file extracts we can see how only one trade contributes to the profit-tracking monitor,
and finally when price reaches the target price the hidden target is processed and all the trades are closed at the same time.

Code: Select all

14:00 GBPUSD: :  updateEntryByUser():  iRunningTrades: 0 bNoStacking: 0 bNowAtMaxStacking: 0 bDoneMaxStacking: 0 bReturnFlag: 0

14:02 GBPUSD: :  bVpoHasBeenTriggered
14:02 GBPUSD: :   Sell, Sz: 0.560, Pc: 1.64637, Sl: 1.64927, Tp: 1.64417, Mg: 600323

1	2014.09.03 14:02	sell	1	0.56	1.64627	0.00000	0.00000	0.00	10000.00
2	2014.09.03 14:02	modify	1	0.56	1.64627	1.64927	1.64417	0.00	10000.00
3	2014.09.03 14:15	sell	2	0.56	1.64579	0.00000	0.00000	0.00	10000.00
4	2014.09.03 14:15	modify	2	0.56	1.64579	1.64927	1.64417	0.00	10000.00
5	2014.09.03 14:30	sell	3	0.56	1.64640	0.00000	0.00000	0.00	10000.00
6	2014.09.03 14:30	modify	3	0.56	1.64640	1.64927	1.64417	0.00	10000.00
7	2014.09.03 14:45	sell	4	0.56	1.64635	0.00000	0.00000	0.00	10000.00
8	2014.09.03 14:45	modify	4	0.56	1.64635	1.64927	1.64417	0.00	10000.00
9	2014.09.03 15:00	sell	5	0.56	1.64628	0.00000	0.00000	0.00	10000.00
10	2014.09.03 15:00	modify	5	0.56	1.64628	1.64927	1.64417	0.00	10000.00

15:30 GBPUSD: M1 :  updateStopLossToXplSl(): , bBuyoldSlGtNewSl: 0, bSelloldSlLtNewSl: 0
15:30 GBPUSD: :  VPO : GBPUSD: Has expired: 2014.09.03 15:30
15:30 GBPUSD: :  updateEntryByUser():  iRunningTrades: 5 bNoStacking: 0 bNowAtMaxStacking: 0 bDoneMaxStacking: 0 bReturnFlag: 0

11	2014.09.03 16:19	sell	6	0.56	1.64646	0.00000	0.00000	0.00	10000.00
12	2014.09.03 16:19	modify	6	0.56	1.64646	1.64927	1.64417	0.00	10000.00
13	2014.09.03 16:43	sell	7	0.56	1.64646	0.00000	0.00000	0.00	10000.00
14	2014.09.03 16:43	modify	7	0.56	1.64646	1.64927	1.64417	0.00	10000.00
15	2014.09.03 16:48	sell	8	0.56	1.64645	0.00000	0.00000	0.00	10000.00
16	2014.09.03 16:48	modify	8	0.56	1.64645	1.64927	1.64417	0.00	10000.00
17	2014.09.03 17:00	sell	9	0.56	1.64626	0.00000	0.00000	0.00	10000.00
18	2014.09.03 17:00	modify	9	0.56	1.64626	1.64927	1.64417	0.00	10000.00
19	2014.09.03 17:16	sell	10	0.56	1.64644	0.00000	0.00000	0.00	10000.00
20	2014.09.03 17:16	modify	10	0.56	1.64644	1.64927	1.64417	0.00	10000.00

17:45 GBPUSD: :  1  $MxPf:33.64  $RPf: 7.32  Pips:2.90  $DdBp:-6.68  $DdAp:-85.08  GapTp:19.10  MnGpTp:14.40
17:45 GBPUSD: :  updateEntryByUser():  iRunningTrades: 10 bNoStacking: 0 bNowAtMaxStacking: 1 bDoneMaxStacking: 1 bReturnFlag: 1

21	2014.09.03 18:08	close	10	0.56	1.64433	1.64927	1.64417	114.84	10114.84
22	2014.09.03 18:08	close	9	0.56	1.64433	1.64927	1.64417	104.76	10219.60
23	2014.09.03 18:08	close	8	0.56	1.64433	1.64927	1.64417	115.40	10335.00
24	2014.09.03 18:08	close	7	0.56	1.64433	1.64927	1.64417	115.96	10450.96
25	2014.09.03 18:08	close	6	0.56	1.64433	1.64927	1.64417	115.96	10566.92
26	2014.09.03 18:08	close	5	0.56	1.64433	1.64927	1.64417	105.88	10672.80
27	2014.09.03 18:08	close	4	0.56	1.64433	1.64927	1.64417	109.80	10782.60
28	2014.09.03 18:08	close	3	0.56	1.64433	1.64927	1.64417	112.60	10895.20
29	2014.09.03 18:08	close	2	0.56	1.64433	1.64927	1.64417	78.44	10973.64
30	2014.09.03 18:08	close	1	0.56	1.64433	1.64927	1.64417	105.32	11078.96


/-----------------------------------------------------------------------
GBPUSD_246_03092014.txt:3256: 17:15 GBPUSD: :  updateEntryByUser():  iRunningTrades: 9 bNoStacking: 0 bNowAtMaxStacking: 0 bDoneMaxStacking: 0 bReturnFlag: 0
GBPUSD_246_03092014.txt:3447: 17:30 GBPUSD: :  updateEntryByUser():  iRunningTrades: 10 bNoStacking: 0 bNowAtMaxStacking: 1 bDoneMaxStacking: 0 bReturnFlag: 1
GBPUSD_246_03092014.txt:3652: 17:45 GBPUSD: :  updateEntryByUser():  iRunningTrades: 10 bNoStacking: 0 bNowAtMaxStacking: 1 bDoneMaxStacking: 1 bReturnFlag: 1

./GBPUSD_246_03092014.txt:4030:18:08 GBPUSD: :  manageExits():  reachedEbpHiddenTarget()
[/size]

I was hoping to have this working on Monday so I could try it out for real, but I still need to check the hidden stop-loss. Also adding a module to parse a string representation of an trade set-up took up quite a bit of time as well. However, it should be useful when pulling trade set-ups from a file.

Forcing a loss to test exit by stealth stop loss:

Code: Select all

11:41 GBPUSD: :  1  $MxPf:13.68  $RPf: -193.88  Pips:-55.20  $DdBp:-73.36  $DdAp:-193.88  GapTp:126.90  MnGpTp:66.10
11:41 GBPUSD: :  manageExits():  reachedEbpHiddenStopLoss()
[/size]
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Dual Channel Breakout

Post by snailbeard »

This is something ZB4 tries to do but not by this visual method I am about to describe:
On AUDJPY M15 for yesterday (10 December 2014) there was an ideal set up with a low risk to high reward ratio, perhaps an ideal candidate for a stacked trade.
AUDJPY-Dual-Channel-breakout-1430-2014-12-11.png
The slow channel is wedge (yellow trend lines) and after about 24 hours we get a 2-bar top, which is a lower high than the one at the start of the channel. The lower channel trend-line is rising from a low. The major break-out will occur either above or below this channel, but there is currently short term ranging inside this wedge shaped channel.

To improve the chance of successfully guessing the longer breakout it helps to look at a H4 chart from which we see the longer term direction is down:
AUDJPY-H4-Long-term-short-2014-12-11.png
On the long term chart we can try to find the most significant support and resistance levels which we can then use on the shorter chart to guage stop-loss and take profit levels.

The purple lines on the first chart give an accurate projection of future support and resistance levels.
The short range channel bounded by red trend lines is steeply upward sloping but runs out of steam at 13:15, the next sequence of M15 bars creates a short range pennant flag and final bar of this has a long pin and small body. This an important precursor and now we are very interested in the following minutes. The following M15 chart is a close-up of the short-range break-out. We can choose one or more rules for entering the breakout. Where E1 is the highest risk and E2 is more cautious and E3 is late or longer term:
AUDJPY-M15-close-up-break-out-1430-2014-12-10.png
Firstly, E1 conforms to my ORFB method (open-reverse-forward break) price reverses for a while but passes the open price in the preferred direction. However, it is on the wrong side of significant support so we might choose to be more cautious like ZB4 and wait for more downward momentum. At E2 we pass another significant level where two recent bars share a close-open level. Finally, we could wait for the current bar to close and say this confirms the break and also we can visualize a new downward short term channel.

The stop loss can be just above the 2-bar top at the yellow line or it could be just above the top Fibonacci level depending on the size of the wikis and there are two main targets, the first one about 80 pips down near Fib100 and an optimistic one near Fib161 returning about 140 pips for a risk of about 15 to 20 pips!
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Slippage

Post by snailbeard »

The user-specified semi-auto-trade entry method has a flaw not present in auto-entry-method which is the user price remains the same while the market price can move quite far from the entry price. Since auto-trader drops VPOs after a while, slippage was handled differently but this had to be rationalized to prevent very late entries.

From the log file we can verify that the new slippage checking is preventing early or late entries. It should be possible to leave ZB4 monitoring a price, come back later and see from the log file if and why a trade was invoked or not.

Code: Select all

12:45 GBPUSD: :  IsPriceSlippageOK(): bTooMuchSlippage  iCurrSlippageInPips: -21 dEntryPrice: 1.60001 dAskPrice: 1.59801 dBidPrice: 1.59791 dCurrSpread: 0.00010 iMaxSlippageInPoints: 100
13:00 GBPUSD: :  VPO : GBPUSD: Has expired: 2014.10.06 13:00

13:00 GBPUSD: :  IsPriceSlippageOK(): bTooMuchSlippage  iCurrSlippageInPips: -13 dEntryPrice: 1.60001 dAskPrice: 1.59878 dBidPrice: 1.59868 dCurrSpread: 0.00010 iMaxSlippageInPoints: 100
 
13:15 GBPUSD: :  VPO : GBPUSD: Has expired: 2014.10.06 13:15
 
13:15 GBPUSD: :  bVpoHasBeenTriggered

13:15 GBPUSD: :   getCurrentSlippage():  iOrderType: 1 OP_SELL  dAskPrice: 1.59910  dBidPrice: 1.59900  dMktPrice: 1.59900  dRequestPrice: 1.59910  pippoint: 0.00010  dCurrSpread: 0.00010  dPriceDrift: -0.00010  testSlippageInPips: 10  testSlippageDecimal: 0.00100  iSlippageNowInPips: -1 bTest: 1 iTestNum: 0
13:15 GBPUSD: :   Sell, Sz: 0.340, Pc: 1.59910, Sl: 1.60644, Tp: 1.59294, Mg: 600323

13:15 GBPUSD: :  doDirectOrder(): iCurrSlippageInPips: -1
[/size]

User specified entries should now enter as expected and be trailed according the selected profit/stop tracking method.

After back testing over several months and improving the logging it is possible to check for problems:
Did a trade occur more than once on the same day?
Did a trade occur too far from the entry price?
Did a trade come close to the trigger but not result in a trade?

So the first and second questions are answered by:

Code: Select all

20141211.log:370: 2	18:42:48	2014.10.06 16:59  GBPUSD,M1: open #1 sell 0.34 GBPUSD at 1.59984 ok
20141211.log:455: 2	18:42:50	2014.10.15 16:31  GBPUSD,M1: open #2 sell 0.34 GBPUSD at 1.59986 ok
20141211.log:479: 2	18:42:50	2014.10.16 00:52  GBPUSD,M1: open #3 sell 0.34 GBPUSD at 1.60000 ok
20141211.log:541: 2	18:42:51	2014.10.23 11:31  GBPUSD,M1: open #4 sell 0.34 GBPUSD at 1.60001 ok
20141211.log:620: 2	18:42:53	2014.10.30 03:04  GBPUSD,M1: open #5 sell 0.34 GBPUSD at 1.59976 ok
20141211.log:654: 2	18:42:53	2014.10.31 01:32  GBPUSD,M1: open #6 sell 0.34 GBPUSD at 1.59992 ok
20141211.log:704: 2	18:42:53	2014.11.03 10:52  GBPUSD,M1: open #7 sell 0.34 GBPUSD at 1.59986 ok
20141211.log:752: 2	18:42:53	2014.11.04 05:26  GBPUSD,M1: open #8 sell 0.34 GBPUSD at 1.59974 ok
20141211.log:797: 2	18:42:54	2014.11.06 07:27  GBPUSD,M1: open #9 sell 0.34 GBPUSD at 1.59978 ok
Found 9 matches for "open #".
[/size]

It would be useful to know if price came close to the trigger price but didn't actually result in a trade:
From the following search there were 25 close encounters spread over 12 separate days
but from above we only had 9 trades so we need to check out the near misses

Code: Select all

grep -nHIirF --include=GBPUSD*.txt -- bEBPCloseToTrigger: 1
./GBPUSD_289_16102014.txt:71:00:29    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_289_16102014.txt:80:00:30    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_289_16102014.txt:89:00:45    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_303_30102014.txt:165:02:53    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_303_30102014.txt:174:03:00    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_308_04112014.txt:260:05:19    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_304_31102014.txt:10:00:00    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_304_31102014.txt:70:00:22    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_304_31102014.txt:89:00:56    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_304_31102014.txt:98:01:00    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_304_31102014.txt:109:01:15    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_304_31102014.txt:118:01:30    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_276_03102014.txt:536:15:49    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_276_03102014.txt:559:16:19    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_276_03102014.txt:569:16:34    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_279_06102014.txt:603:15:07    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_279_06102014.txt:669:16:50    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_296_23102014.txt:453:11:31    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_288_15102014.txt:544:16:03    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_288_15102014.txt:554:16:28    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_288_15102014.txt:564:16:31    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_310_06112014.txt:294:07:26    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_307_03112014.txt:429:10:50    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 

./GBPUSD_302_29102014.txt:818:22:47    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
./GBPUSD_302_29102014.txt:830:23:01    doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 
Search completed with 25 matches.
[/size]

After cross checking:
one of those days was a Friday afternoon after my last allowed entry time:

Code: Select all

16:15 GBPUSD: :   doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 0 iOrdertype; 1 EBP_TriggerPrice: 1.60001 EBP_CrashStopPrice: 1.60644 EBP_CrashTargetPrice: 1.59294
16:19 GBPUSD: :   doEnterByPrice(): setVpo:  bEBPCloseToTrigger: 1 iOrdertype; 1 EBP_TriggerPrice: 1.60001 EBP_CrashStopPrice: 1.60644 EBP_CrashTargetPrice: 1.59294
16:22 GBPUSD: :  bVpoHasBeenTriggered: (bValidTradeTime == false) -> clearAllVpo()
[/size]

And the other one on 29th October 2014 was a genuine near miss:
gbpusd-m15-EBP-near-miss-2014-10-29.png
According to these final test results I now feel confident enough to leave ZB4 running with a user's predetermined entry. Without the EBP date parameter this same price will be monitored every day although it would be more usual to change the settings day by day.
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Poor trade management

Post by snailbeard »

Although I have discovered many ways of spotting good trades there are even more ways to get it wrong or mess up a perfectly good trade. In this H4 chart we can see how a perfectly good trade should have been allowed to run to take profit but instead a premature exit occurred:
gbpusd-h4-poor-trade-management-2014-10-31.png
It seems that only 19 pips were taken and 50 pips were left behind

With reference to the log file it is easy to find out where the bug is:

09:09 GBPUSD: : Updated symbolLockAccPercent : 0.69
09:26 GBPUSD: : GBPUSD, orders closed at: 0.69 ,Symbol trailing percent level, 844484

A first guess would be that 0.69 should be (1.0 - 0.69)
and perhaps if our stops are wide enough we don't even need the trailing profit locking, it all depends on the market and how confident you are about the current swing.

After looking at the trailing logic the problem is related to risk management:
The auto trades work on the basis of a 1% risk and so a trailing profit is based on this
where
trailing doesn't start until
symbolTrailPercentLevel = 0.90
which means when the trade has reached 90% of its target start locking profit
symbolTrailFractionToLock = 0.75
means try to lock at least 75% of the 1% risk after trailing has started

Since I have manually chosen a lot size with say a 2% risk these numbers no longer make sense.
For this to make sense 0.90 should relate to the maximum profit (actual risk) rather than the theoretical risk.

After changing trailing percent this particular trade no longer gets close enough to the target to start the profit locking because it overlaps with Friday's early exits:

This confirms that Friday exit check is working:

Code: Select all

16:12 GBPUSD: :  iCPTicketNum : 1, dSymSumCashProfit 76.79, symbolPercentUp : 0.84
16:13 GBPUSD: :  Clock: FridayExitGMTHour && FridayExitMinute: 16:13
16:13 GBPUSD: :  iCPTicketNum : 0, dSymSumCashProfit 98.89, symbolPercentUp : 1.08
[/size]

However, we can see that after this trade the next two entries go much closer to the 2% target:

Code: Select all

------------------------------------------------------------------------
13	2014.10.30 03:04	sell	5	0.34	1.59976	0.00000	0.00000	0.00	9186.91
14	2014.10.30 03:04	modify	5	0.34	1.59976	1.60644	1.59294	0.00	9186.91
15	2014.10.31 16:13	close	5	0.34	1.59677	1.60644	1.59294	98.89	9285.80
------------------------------------------------------------------------
16	2014.11.03 10:52	sell	6	0.34	1.59986	0.00000	0.00000	0.00	9285.80
17	2014.11.03 10:52	modify	6	0.34	1.59986	1.60644	1.59294	0.00	9285.80
18	2014.11.05 11:06	close	6	0.34	1.59343	1.60644	1.59294	215.04	9500.84
------------------------------------------------------------------------
19	2014.11.06 07:27	sell	7	0.34	1.59978	0.00000	0.00000	0.00	9500.84
20	2014.11.06 07:27	modify	7	0.34	1.59978	1.60644	1.59294	0.00	9500.84
21	2014.11.06 14:56	close	7	0.34	1.59340	1.60644	1.59294	214.96	9715.80
------------------------------------------------------------------------
[/size]

and we can check this against the log file:

Code: Select all

11:06 GBPUSD: :  iCPTicketNum : 1, dSymSumCashProfit 215.04, symbolPercentUp : 2.32
11:06 GBPUSD: :  GlobalVariableCheck : sLockName: GBPUSD600323_trailingSymbol, symbolLockAccPercent 1.78
11:06 GBPUSD: :  Previous symbolLockAccPercent : 1.779, runningFractionToLockLevel: 2.135
11:06 GBPUSD: :  manageExits():  reachedEbpHiddenTarget()
[/size]

It looks like there is just one more thing to do on user specified Enter-By-Price which is to be able to specify a risk-level instead of a lot-size then derive the lot-size from the risk level.

After specifying an EBP risk value of 1% the following lot-size is used to override the given lot-size:

Code: Select all

calcLotSizeFromRisk():  
dGapInPoints: 0.00543 
dExposureByRisk: 96.24681 
LotStep: 0.01000 
MinLotSize: 0.01000 
dTickValue: 1.00000 
dUnitDecimal: 0.00001 
dLotSize: 0.17725 
iWholeSteps: 17 
dRoundedLotSize: 0.17000
[/size]
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Worst spreads

Post by snailbeard »

Which Broker's should we avoid due to high spreads on crosses?

At lot of brokers will show low spreads on the majors and in their advertising, but what if you want to trade crosses as well?
Example AUDJPY snapshot of spreads from MetaCrap:
Worst Spreads First:
Alpari AUDJPY 5.0 to 6.0 pips
FxPro AUDJPY 2.0 to 3.0 pips
FxOpen AUDJPY 1.0 to 2.0 pips
GlobalPrime AUDJPY 1.0 to 2.0 pips

Here is a much more comprehensive snapshot courtesy of myFxBook:
(commissions are included)
snapshot-of-broker-spreads-15Dec2014.png
Should we have a competition for the worst and best spreads?
So far Fat-Spread Alpari is leading the worst spreads. Our honest resident broker Global Prime is in the middle, and leading the lowest spreads is PureECN who is based in New Zealand, I don't know anything about them, but if you are happy or unhappy with them please share your experiences.

When I was rookie I opened an account with Alpari and IG and since they are market-maker accounts they gain when their customers lose money. If I wanted to play against the house I could just go to a casino and play roulette.

Thanks to Steves's forum I learned a lot about the criminal activity of some brokers and now know the difference between MM, STP and ECN,
where STP is supposed to mean Straight-Through-Processing but it is not the same as ECN.
STP is supposedly less prone to manipulation by brokers but I can't tell if this is case or not...

One of our members has posted a list of true ECN brokers but this is now out of date:

http://www.stevehopwoodforex.com/phpBB3 ... =28&t=3389

Of course brokers and banks are not the only sources of criminality for us smaller traders, we could also be affected indirectly:
https://www.infosecurity-magazine.com/m ... round-for/

PureECN might be winning the low-spread contest but who are they?
Who can vouch for them?
There is no review in forexpeacearmy
and scamadvisor says 70% safe

http://www.scamadviser.com/is-pureecn.net-safe.html

What does scamadvisor say about our friends:
http://www.scamadviser.com/check-websit ... ime.com.au
Which is comforting.

Many traders have complained in forexpeacearmy about the difficulty of withdrawing funds from their brokers and it seems to be a common problem.

There is still more work to be done on selecting several safe and dependable brokers.

One more thing to watch out for is jumps in the ECN spreads: even though I would have expected several ECN brokers to have similar spread variations, Exness had several jumps in their AUDJPY spread which briefly put them on a par with Fat-Spread-Alpari so it might be necessary look at the liquidity providers of the brokers more carefully:
exness-peak-spread-variation-2014-12-12.png
Thanks again to myfxbook for publishing this data on their website.
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Dynamic range

Post by snailbeard »

I have not had much time to develop the candle-slope method. Most of my effort has been to reduce over filtering of good entries. Last week I found some ways to improve the end-of-swing/end-of-range checks. Sometimes price swings a lot but then price comes back close to an earlier price therefore the price has not changed that much and there might be scope for real price change.

Thanks to those changes ZB4 finds 3 successive daily trades in the middle of September. Previously, ZB4 had chucked out two of those 3 trades.

Just as important is the work to set the right stop-loss and target. To help with this I look at distance between the daily pivots; the weekly pivots; the D1 ATR and H4 ATR. These all have problems in that they are lagging the current price action. H4 ATR is the least lagging and the size of H4 candles are important as well, as the size of reverse H4 candles. So often the entry is good but the trade is too tight. The PACL method was implemented to cope with the reduced price swings before the summer but in September we had some good swings but with bigger reversals as well.

It is now possible to control the maximum and minimum PACL stop-loss with a couple of parameters:

Code: Select all

extern double PaclAbsMinStopLoss = 15.0;
extern double PaclAbsMaxStopLoss = 30.0;
[/size]

However, in this back test ZB4 is just inside these manual limits but with reference to the chart below, we can see that price action has notched up a gear and so have the reversals. Perhaps ZB4 should not be using the PACL method or it needs better control of the stop-loss and target:

Code: Select all

22	2014.10.02 13:56	sell	8	0.41	1.61449	0.00000	0.00000	0.00	10650.17
23	2014.10.02 13:56	modify	8	0.41	1.61449	1.61728	1.61206	0.00	10650.17
24	2014.10.02 16:16	s/l	8	0.41	1.61728	1.61728	1.61206	-116.77	10533.40

SL: 1.61728 - 1.61449 = 0.00279 :: 27.9 pips (not enough)

Requires a longer trade: H4 ATR is 43; Gap between WS1 and WP = 116 and half of that is 58
[/size]
GBPUSD-H4-better-dynamic-range-and-stoploss-02Oct14.png
From the chart we can see that a recent past H4 bar reversed more than the current stop-loss setting.
After entering the trade, price reversed just over 30 pips, but it could easily have been 50 or 60 pips so this entry doesn't make sense.

Hopefully, the log file will tell why ZB4 chose a short trade instead of a longer PBRE trade...

A couple more things to observe:
a) This trade is a H4LbbBkOut (lower Bollinger Band (green)) break-out entry.
b) There were potential entries several times when price reversed across H4 MBB and recrossed down in the dominant down direction. I have noticed quite a few occasions when this is a reliable entry method provided that there is a definite trend. These double-crossings might currently be too fast and difficult to quantify in real-time for ZB4, but I'll be looking into capturing some of these events as triggers...
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

False H4 & D1 reversals

Post by snailbeard »

Several of ZB4's filters deal with reversals. Computing the difference between a real reversal and a pullback followed by a reentry into the current direction is full of pit falls. This is particular true on the H4 time frame. When we look back historically it is easy to see several entry points when price re-crosses the H4 mid-Bollinger band in the dominant longer term direction. However, our brains are very good at ignoring the places where these crosses would result in a false re-entry. The problem is compounded by the deficiencies of the real-time zig-zag algorithm which regularly identifies false turning points.

In the following chart I have labelled the real and some of the false zig-zag pivots relating to the beginning of October as I would like to be able to catch price moving back with the main swing. There are many false zigzag pivots and labelling them all would be very tedious. I have already done some work to discount some false reversals. There is an obvious trap here in that if we ignore reversal signals then there will be a lot of wrong entries. So I'm looking for a method which would be correct at least 2-to-1 or preferably 3-to-1.

Several things to note are
a) H4 should have steeper swings than D1 most of the time because generally the H4Zz swings backwards and forwards across the mean of the daily change.
b) The length of a H4Zz or D1Zz swing should not be too short.
c) A reversal which starts outside a D1 Bollinger is likely to be stronger than a shorter swing which begins a reversal inside a Bollinger.

None of these observations are particular useful as they are vague and difficult to quantify.
gbpusd-h4-false-D1Zz-reversal-02Oct14.png
After some tweaking and a new entry detection method there were two H4-MidBB crossing entries:

Code: Select all

1	2014.09.30 12:28	sell	1	0.43	1.62078	0.00000	0.00000	0.00	10000.00
2	2014.09.30 12:28	modify	1	0.43	1.62078	1.62324	1.61866	0.00	10000.00
3	2014.09.30 13:42	close	1	0.43	1.61885	1.62324	1.61866	80.48	10080.48
4	2014.10.02 09:47	sell	2	0.42	1.61972	0.00000	0.00000	0.00	10080.48
5	2014.10.02 09:47	modify	2	0.42	1.61972	1.62216	1.61730	0.00	10080.48
6	2014.10.02 12:09 	t/p	    2	0.42	1.61730	1.62216	1.61730	99.19	10179.67
[/size]

Looking at the log file

Code: Select all

09:45 GBPUSD: :  st_bM15OC_BelowH4MBB: sc_M15OC_BelowH4MBB: 314

bM15OpenCloseToH4MBB: bM15OC_BelowH4MBB: bH4MbbReEntryDown
[/size]

The first part: st_bM15OC_BelowH4MBB indicates that we missed the actual crossing of H4-MidBB but entered shortly afterwards. The second part just keeps track of the of times this condition was true.
The actual entry signal is 'bH4MbbReEntryDown'. This was only possible by having another flag to ignore the H4 reversal flags. So the next step is to see how many false entries occur over a longer period of testing.

Running the test over a longer period did better than expected with only one failure:

Code: Select all

1	2014.09.17 09:41	buy	1	0.38	1.62961	0.00000	0.00000	0.00	10000.00
2	2014.09.17 09:41	modify	1	0.38	1.62961	1.62672	1.63182	0.00	10000.00
3	2014.09.17 10:53	t/p	1	0.38	1.63182	1.62672	1.63182	81.75	10081.75
4	2014.09.18 10:57	buy	2	0.32	1.62957	0.00000	0.00000	0.00	10081.75
5	2014.09.18 10:57	modify	2	0.32	1.62957	1.62637	1.63269	0.00	10081.75
6	2014.09.18 13:46	close	2	0.32	1.63268	1.62637	1.63269	97.64	10179.39
7	2014.09.19 00:12	buy	3	0.28	1.63958	0.00000	0.00000	0.00	10179.39
8	2014.09.19 00:12	modify	3	0.28	1.63958	1.63561	1.64289	0.00	10179.39
9	2014.09.19 00:33	t/p	3	0.28	1.64289	1.63561	1.64289	91.03	10270.42
10	2014.09.30 12:28	sell	4	0.45	1.62078	0.00000	0.00000	0.00	10270.42
11	2014.09.30 12:28	modify	4	0.45	1.62078	1.62324	1.61866	0.00	10270.42
12	2014.09.30 13:42	close	4	0.45	1.61885	1.62324	1.61866	84.22	10354.64
13	2014.10.02 09:47	sell	5	0.43	1.61972	0.00000	0.00000	0.00	10354.64
14	2014.10.02 09:47	modify	5	0.43	1.61972	1.62216	1.61730	0.00	10354.64
15	2014.10.02 12:09	t/p	5	0.43	1.61730	1.62216	1.61730	101.55	10456.19
16	2014.10.03 10:01	sell	6	0.39	1.61179	0.00000	0.00000	0.00	10456.19
17	2014.10.03 10:01	modify	6	0.39	1.61179	1.61458	1.60916	0.00	10456.19
18	2014.10.03 11:18	close	6	0.39	1.60922	1.61458	1.60916	97.97	10554.16
19	2014.10.13 17:46	sell	7	0.35	1.60715	0.00000	0.00000	0.00	10554.16
20	2014.10.13 17:46	modify	7	0.35	1.60715	1.61031	1.60431	0.00	10554.16
21	2014.10.13 23:31	s/l	7	0.35	1.61031	1.61031	1.60431	-112.63	10441.53
[/size]
You do not have the required permissions to view the files attached to this post.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

EURUSD - how low can you go?

Post by snailbeard »

I remember reading in money week several years ago that the Euro was likely to collapse in 2013. So here we are at the end of 2014 and Euro has never looked healthier :lol: So the only thing we can be sure about is that the experts don't know s***, although perhaps eventually the collapse could come tomorrow or next week or next year or 2016, probably when our attention is somewhere else.

The Euro looks particularly anaemic at the moment but can it go much lower. Volume has really dropped off:
eurusd-W1-end-of-year-low-2014.png
The Euro has been this low before and is approaching a historical low, last time it started to reverse long term but I'm not making any predictions...
eurusd-W1-repeat-low-2011-to-2014.png
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “Automated trading systems”