Showing posts with label FIBONACCI. Show all posts
Showing posts with label FIBONACCI. Show all posts

Wednesday, 9 November 2011

Now that really ticks me off (Why testing with tick data can be 99% wrong!)

Dontcha just hate it when you spend the weekend back-testing your latest software, only to get disappointing results when you forward test the next week. Where did I go wrong? How can this be happening?

One often mooted reason is the data used for the back-test. If the data is not representative of the live environment, our test results are not likely to be reflecting anything near reality.

Of course, there is the argument that back-testing is intrinsically useless because the future does not reflect the past. Well, a brazillion (large number) folks would disagree. I include among those any trader that uses a support or resistance point, Fibonacci projection or similar in their strategy. What else do these demonstrate but market memory? I digress ...

The list of problems with data includes:

Difference between demo and live: Even if you recorded tick data yourself from a demo server, it may not reflect what is happening on the same broker's live server. Big and frequent differences point to the need to look for a new broker.

Data not reflecting "market" liquidity provider sentiment: Foreign Exchange is a huge market. Retail brokers only have a (usually small) slice. Their quotes will reflect that small share, plus their own spreads to reflect their trading position (after all the majority are actively trading against you). I don't want to reiterate the list of broker "dirty tricks" in this article. Dump a months worth of M1 data, come back a month later and look at the historic data currently shown. You will often find peaks/troughs disappear. These are artificially jacked quotes designed to knockout trade stop losses.

Data gaps: Wow! look at that hugely profitable renko trade! Unfortunately the untradeable stream of bricks produced by my chart generator were entirely due to the gaps in the data I used.

Data granularity: Using 1 minute closes to test a scalping system may not be the optimal method, especially if your system artificially generates ticks based on the Open, High, Low and Close of that bar. Metatrader, for example, uses a technique called fractal interpolation to generate fake ticks from the summary bar data.

Data obtained from a different broker: It goes without saying that testing with data from a different broker has its problems, results depending entirely on the correlation between them and prices from the target broker.

Applications requiring volume as a key parameter: Some providers dont provide volume at all with their data (e.g. Gain Capital). Some provide bid and ask volume separately (e.g. Dukascopy). It is questionable in many cases whether the volume numbers are representative of anything.

It's all in the percentages

Bwa ha ha ha! Sorry, let me pick myself up from the floor and dust myself off. There is sooooo much BS talked about 99% vs 25% tick data that I have to expose this right away. I refer to the test summary report MT4 produces when doing back-testing. If you use fractal interpolation, the percentage will be low, like 20 to 25%, right? But if you have tested with good quality data, the percentage will be high, like 99%, right? WRONG! The 25% figure is a number that the strategy tester in MT4 writes into the tick data file. The 99% figure is a number that the PROGRAM that generated the data writes into the tick data file. Simple as that. In version 406 of MT4, it is a double value written to  bytes 232 to 239 of the file. Any reprobate could fake the "quality" of data used in their testing using a very simple program.

Warning note: MT4 tick data DOES change sometimes from build to build. Please ensure you are using tick data generated for your build, especially if you purchase it.

Solution

There are several solutions to the issues mentioned above, and whichever you take will depend on the type of testing you want to do, whether you are scalping or working on longer time-frames, using time-based or price-based charts.

Some very nice scripts are freely available for downloading, and given time, one can become very proficient at using them. One problem for me is that they usually run very slowly, very frustrating for me if I want to generate a tick data set for several currencies and time-frames on the fly. Being time-conscious, I had to bite the bullet and spend some time, firstly deciding what approach suited me, and then implementing a system. The beauty of porting to a more modern environment such as VB/Java/C++ allows me, as a programmer, to revisit all of the programmer decisions that must have been made multiple times by the various implementers. e.g. Once you move out of MQL4, you need to implement your own StrToTime function, which is fun! As I mentioned previously, quick access to representative source data is important to me, so using Dukascopy with its wacky interface is largely out of the question. My choice of data provider allows me to download in bulk, on the fly, in a matter of minutes. My new system allows me to quickly convert this into a tick data file with 99% quality (or is it 100%?), (big smile .....). BTW, did I mention it can also generate renko tick data?

Friday, 18 February 2011

110118 - Float like a Butterfly, sting like a.... errr ... Crab? - Harmonic Patterns

Oooh Daddy, look at the beautiful butterflies ....
I have long been interested in harmonic patterns. The basic premise is that there are certain shapes in the price series which empirically suggest what will happen next. Whether or not you give this any credence or not, it is an interesting study, the by-product of which can be much valuable market insight.

Harmonic patterns are based on Fibonacci retracements, i.e determining where a "golden" ratio of peaks vs troughs exist, and buying/selling accordingly. Putting the numbers to one side (we will come to that in a moment), to me it is quite intuitive to say that a price may rise after it has made a significant fall (bullish signal), or fall after it has made a significant rise (bearish signal).
Gartley 222, named after page 222 of Gartley's book!
There are many websites that describe both harmonic patterns and Fibonacci ratios, so I will not repeat that work here. My favorite site is http://www.harmonictrader.com/price_patterns.htm
Whether or not you believe that Fibonacci numbers actually work, there are perhaps so many market participants who do, that it is a self-fulfilling prophecy, and that could be true of any such empirical signal. Imagine 25,000 harmonic pattern traders saying "OMG, there's a bearish bat formation, sell the farm ......".

One of the drawbacks with Harmonic Patterns, for many retail traders, is that to see a significant amount of patterns, you need a lower timeframe. If you study 4 hour charts, classic patterns except for Fibonacci retracements are few and far between, that is why most pattern indicators have a tolerance input, which you can increase to get more patterns. Of course, this potentially invalidates some signals. I think this explains the continuing amount of new patterns being invented, as the majority of retail FX traders don’t make trades based on H4 signals and then keep the trade on for a month. Probably due to boredom. My pattern indicator detects and displays:

AB=CD
Bat
Butterfly
Crab
Fibonacci Retracements
Gartley
5-0

Bearish AB=CD
You will observe many more Fibonacci retracements than full classic patterns. If you recall that ALL classic harmonic patterns have some Fibonacci retracement component, then that’s not surprising. By default, my indicator has Fibonacci retracements turned off. Not that I don’t think they are valid, merely because most people who are interested in the indicator want to see the larger patterns. Of course you can reverse this, and just trade the Fibos alone.

The majority of commercial indicators are repainting, and use a method of determining retracements which means they miss the trade entry by a considerable margin. They do not include easily accessible signal buffers.

You can tell that these indicators have been written by very clever individuals, given the amount of signals and measurements produced. Do users really want to see the results in a zillion different muddy colours, or would they rather understand that the patterns are displayed on a colour cycle that is easy on the eye when the user is staring at the screen for 8 hours? Does the indicator perform well in real-time? Try setting your favourite pattern indicator to have a 10,000 bar history, and attach it to an EA in the strategy tester. In visual mode, move the speed control to the extreme right (fastest). Does it keep up or does it stutter with the load? This is a measure of  “On-Off” ratio and shows how much of your system resources the indicator will use. In the same test, does it give multiple signals at slightly different bars on each bar open? That is the difference between writing code and production engineering.

Bearish 5-0
For most types of trading, stops and profit targets are the key to successful trades. When the indicator gives you a valid bullish signal, you still need to know how big your stop should be and where your profit target is. There is a whole other layer that needs to be put on top of this or any other indicator to achieve that automatically.