Zigzag Bollinger Band

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

Zigzag Bollinger Band

Post by snailbeard »

According to the next chart, in which we can see zig-zags and Bollinger Bands:
Pullback-Rentry has become locked in antiphase to the swings of the zig-zags and throwing away our recently hard earned profits.
It should be possible to resynchronise our confused PBRM by getting it to swing with the zig-zags instead of against them.
Of course we still have the issue of zig-zags which frequently adjust the most recent node, but the older nodes are stable.
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

Zigzag Bollinger Band

Post by snailbeard »

After experimenting with various geometrical calculations, I now have a collection of predicates about the state of the market. It is not just a question of dropping bad trades by filtering out certain combination of factors, which is one reason why ZZBB misses lots of good trades. Since one entry method is sometimes in antiphase to the appropriate direction to trade, it would better to turn bad trades into opportunities.

The first stage is to understand how the proposed trades are invalid.
The previous 3 failed trades are dissected minutely until there is enough information to make considered decision whether or not to drop these candidate trades.
So far this is working well when volatility is lower and daily change in price is also lower.

I nolonger get the 3 bad trades, but can we resuse the same analysis to find out when it might be good time to buy or sell?

Since those trades occured at 01:16, 05:02 and 13:02, we might ask the question how can we call this intraday trading for the first two trades when the day is still evolving. Not only that, but refering back to the previous chart: there were 3 major reversals in a single day. Our function has to be as dynamic as the market or we'll be still buying when the market reverses.

The following data dump from the first candidate trade shows a lot of useful things about the market at the moment:
1 2012.11.09 01:16 sell 1 0.30 1.03930 0.00000 0.00000 0.00 10000.00
2 2012.11.09 01:16 modify 1 0.30 1.03930 1.04230 1.03680 0.00 10000.00
3 2012.11.09 03:12 s/l 1 0.30 1.04230 1.04230 1.03680 -90.00 9910.00

10:55:37 2012.11.09 01:15 SB_MT4v600-compatible AUDUSD,M1: calcIntraDaySlope(): , bD0OpenLowToHigh: 0, bD0OpenHighToLow: 0, bD0OpenLowToHigh2: 0, bD0OpenHighToLow2: 0
, bMoreHigherHigh: 0, bMoreLowerLow: 0, bHigherHighH8: 0, bLowerLowH8: 1
, st_bSlopeConflicted: 1, st_bBreakOpenRepeated: 1, st_H24Direction: 0, iResultDirection: 0
, st_bHasSlope: 0, st_IntradDaySlopeDropped: 1
, st_bIDSWR_SellFlag: 0, st_bIDSWR_BuyFlag: 0, iSwingDirectionNow: 0, st_bCloseToH24Swing: 1
, iCountHigherHigh: 2, iCountHigherLow: 1, iCountLowerHigh: 1, iCountLowerLow: 2
, bAtLeastOneHH: 1, bAtLeastOneLL: 1, iCountPredicateHH: 0, iCountPredicateLL: 1
, dGapToH4LowInPips: 15.20, dGapToH4LowInMins: 45, dGapToH4HighInPips: 15.80, dGapToH4HighInMins: 210
, dGapToH24LowInPips: 15.20, dGapToH24HighInPips: 49.80, dH24SwingInPips: 65.00, st_bGoodVolatility: 1
, st_bNoRoomToTrade: 0, st_bTooCloseToLow: 1, st_bTooCloseToHigh: 0
So the key boolean in the above is
st_bTooCloseToLow: 1
which stops us jumping into a swing which could be about to reverse,
but we can't just switch from a sell to buy just because it might reverse, there needs to some hint the price is moving the opposite way.

Moving along the time line to 2am in the morning CET, something interesting happens
2012.11.09 02:00 SB_MT4v600-compatible AUDUSD,M1: calcIntraDaySlope(): , bD0OpenLowToHigh: 0, bD0OpenHighToLow: 0, bD0OpenLowToHigh2: 0, bD0OpenHighToLow2: 0
, bMoreHigherHigh: 0, bMoreLowerLow: 1, bHigherHighH8: 0, bLowerLowH8: 1
, st_bSlopeConflicted: 1, st_bBreakOpenRepeated: 1, st_H24Direction: 0, iResultDirection: 0
, st_bHasSlope: 0, st_IntradDaySlopeDropped: 1
, st_bIDSWR_SellFlag: 0, st_bIDSWR_BuyFlag: 1, iSwingDirectionNow: 1, st_bCloseToH24Swing: 1
, iCountHigherHigh: 1, iCountHigherLow: 1, iCountLowerHigh: 2, iCountLowerLow: 2
, bAtLeastOneHH: 1, bAtLeastOneLL: 1, iCountPredicateHH: 0, iCountPredicateLL: 2
, dGapToH4LowInPips: 19.20, dGapToH4LowInMins: 90, dGapToH4HighInPips: 7.80, dGapToH4HighInMins: 241
, dGapToH24LowInPips: 19.20, dGapToH24HighInPips: 45.80, dH24SwingInPips: 65.00, st_bGoodVolatility: 1
, st_bNoRoomToTrade: 0, st_bTooCloseToLow: 1, st_bTooCloseToHigh: 0
Firstly we have one flag waving which says don't believe the general slope
st_IntradDaySlopeDropped: 1
and we have another flag waving:
st_bIDSWR_BuyFlag: 1
which means there is an 'Indraday Swing Reversal' in favour of buying.

So it will be interesting to see how well this works in practice,
or to find out when it works well and when it doesn't.
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Chasing the dragon

Post by snailbeard »

After integrating the additional entry method (intraday swing reversal), it has been possible to avoid 3 losing trades and replace them with alternative opposite and winning trades.
We don't need to stop here, if we allow overlapping trades we can probably get shadow entries on two of the trades which have significant pullbacks.
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

Fibonacci projections

Post by snailbeard »

Some brief thoughts on calculating weekly Fibonacci projections to help locate likely end of swing:

Note:
if W[1] change was small compared to W[2] change
perhaps W[1] is a pullback
and W[1] could be consolidation

Example:

AUDUSD 2012 October/November

Finding projections for 4th to 8th Nov
from W[1] and W[2]
End of range for W[0] from W[1] corresponds to Fibo 424
which corresponds to Fibo 262 of W[2]
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Weekly Fibonacci Levels

Post by snailbeard »

I have discussed Fibonacci levels many times, but I have just now got around to making them useful. It occurred to me some time ago that if I was using a proper programming language instead of MetaCrap, then I could use generic methods to calculate the Fibonacci levels on several times and tag the strong levels where there is a coincidece of lower timeframe levels with higher timeframe levels.

So far all I have managed to do is implement the weekly cycle, although it might not be exactly one week.

First the problem to be solved:

The IntraDay Slope is often correctly deduced but sometimes price meets a significant Fibonacci level and starts moving in reverse to the current swing. Sometimes the H4 chart is much more useful for spotting these levels.

Firstly, looking at a problem entry on this M15 chart, we have a strong reversal from a super node. After one day we have a pretty convincing stepping down. If you are trading on a higher time frame with longer targets and stoplosses, you cound enter short and hold, but then again the market makes no promises.
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

Weekly Fibonacci Levels

Post by snailbeard »

Now looking at same period on the H4 timeframe: the respective close of the latest H4 candles have a close relationship to the Fibonacci levels, ( the close of the two large down bars are above the Fibonacci levels, warning us not to go short for the time being:
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

Fibonacci pulback and reversal

Post by snailbeard »

Firstly, we need to determine where we are in the weekly Fibonacci context
dW1SwingInPips: 124.00,
iH24SwingInPips: 55.00
dFiboNearest: 1.05230,
dGapToFiboLevelInPips: 3.00,
bCloseToFiboLevel: 1,
iD4FiboClosestLine: 3
bH4CloseAboveFiboLevel: 1
Form this we then determine if there is a significant pullback and whether or not price bounced off the significant level or was allowed to pass:
st_bRejoining4D1Swing: 1,
bFiboBounceFlag: 1,
iFiboBounceDirection: 1
So normally, this would be a clear-cut break-open-repeated sell entry, but checkFibo intervenes, and hands control to the swing logic, which calculates the scope for a buy trade against the daily momentum:
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

Zigzag Bollinger Band

Post by snailbeard »

The new entry methods are very profitable when used with the right parameters and in an appropriate market.
However, the market will take it all back with interest if they are used inappropriately.
In the attached image we see a great month with AUDUSD in December, but long term ATR has been falling for some time and Janary 2013 turns into a pig of a month with ranging and strong reversals while long term ATR has been dropping off and reaches a minimum January.
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

Flag waving day

Post by snailbeard »

Today is flag waving day, or rather a day for inspecting flags.

Are you writing your own autotrader?
Do you have difficulty understanding what is going on inside your code?
This often happens to me after a small idea turns into a lot of code.
Why is my new code always full of holes?

I think it is because I am trying to do too many things at once:
Firstly, part of my brain is occupied with technical analysis, then another part has an idea, and yet another part is trying think how that could work in maths and logic, but still another part has to translate that into a programming language then there are hours of typing, typos, cutting and pasting and forgetting to finish some of the changes. The whole thing is a mess and by the time I'm done I have probably forgotton half of the original idea.

So in response to these limitations I have evolved a method of working, which means more typing, but also saves time in the long run. This involves creating a lot of extra boolean flags for intermediate steps.
When the market data used has about equal measures of upness and downness there should be similar number of counts for opposite flags.

I have recently found it necessary to reimplement the zigzag analysis as part of improving the frequency of trades and the quality of entries, as well the reverse of inhibiting the opposite trades when zigzags clearly tell us not to go the opposite way.

After a shed-load of analysis everything gets boiled down into a small number of flags.
I then use an editor to process the log file to give me a summary
like so:

Code: Select all

Found 107 matches for "st_bM15ZZ_M15StrongUp 1, st_bM15ZZ_M15StrongDown 0".
Found 112 matches for "st_bM15ZZ_M15StrongUp 0, st_bM15ZZ_M15StrongDown 1".
Found 1319 matches for "st_bM15ZZ_M15StrongUp 0, st_bM15ZZ_M15StrongDown 0
Found 0 matches for "st_bM15ZZ_M15StrongUp 1, st_bM15ZZ_M15StrongDown 1

Found 1365 matches for "st_bM15ZzTriNodeBuy 0, st_bM15ZzTriNodeSell 0".
Found 94 matches for "st_bM15ZzTriNodeBuy 1, st_bM15ZzTriNodeSell 0".
Found 79 matches for "st_bM15ZzTriNodeBuy 0, st_bM15ZzTriNodeSell 1".
Found 0 matches for "st_bM15ZzTriNodeBuy 0, st_bM15ZzTriNodeSell 1".

Found 2 matches for "st_bM15ZzNoSellFlag 0, st_bM15ZzNoBuyFlag 0".
Found 58 matches for "st_bM15ZzNoSellFlag 1, st_bM15ZzNoBuyFlag 0".
Found 0 matches for "st_bM15ZzNoSellFlag 0, st_bM15ZzNoBuyFlag 1".
Found 1478 matches for "st_bM15ZzNoSellFlag 1, st_bM15ZzNoBuyFlag 1".

Found 0 matches for "st_bH1ZzNoSellFlag: 0, st_bH1ZzNoBuyFlag: 0".
Found 30 matches for "st_bH1ZzNoSellFlag: 1, st_bH1ZzNoBuyFlag: 0".
Found 2 matches for "st_bH1ZzNoSellFlag: 0, st_bH1ZzNoBuyFlag: 1".
Found 1506 matches for "st_bH1ZzNoSellFlag: 1, st_bH1ZzNoBuyFlag: 1".
This approach can often highlight a defect before other checks.
In the above I am concened about the discrepancy between

Code: Select all

Found 58 matches for "st_bM15ZzNoSellFlag 1, st_bM15ZzNoBuyFlag 0".
Found 0 matches for "st_bM15ZzNoSellFlag 0, st_bM15ZzNoBuyFlag 1".
Why are they so different? Shouldn't they be similar?
This saves time carefully going through the strategy tester results one trade at a time.

So what has been described is one aspect of 'defensive programming'.
It can result better and more robust code.
There is a lot more that can be done and if you are just starting out on a new project you might find some of the following links interesting:
http://word.mvps.org/FAQs/MacrosVBA/Mai ... leCode.htm
http://devmethodologies.blogspot.co.uk/ ... mming.html
http://www.eetindia.co.in/ARTICLES/1999 ... S=DOWNLOAD
http://word.mvps.org/FAQs/MacrosVBA/Mai ... leCode.htm
User avatar
snailbeard
Trader
Posts: 615
Joined: Mon Dec 24, 2012 10:54 am
Location: Just above water somewhere between Oxford & Cambridge

Bad Day At Black Rock

Post by snailbeard »

I have been busy hardening SB-NG and running it on some wild markets.
There was plenty of violence in July and August 2012 and a lot of fatally wounded traders no doubt.

I recently noticed how some of the big boys are doing their moves. On this chart the Money-Movers wind up the tension in the morning. At 10:45 they launch their attack grabbing plenty of pips. Soon afterwards a crowd of DPA (Dumb Price Action) traders try to get in on the action falling into a well laid ambush. MM unloads and price goes back down.

At 'A' something unexpected happens SB-NG enters, grabs 20 pips and gets out at 'B' using its counter swing method,

However, that wasn't why I was looking at this particular day. The real move begins after the blood-bath, at 19:30 volatility has collapsed. The MMs have walked away with their loot and gone home. Now natural forces are at work and there is a definite sequence of lower highs, after a significant top. I should be getting an entry after C and possibly at D but something has got lost in the second order logic.
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “Automated trading systems”