I see that more and more people are using loss averaging martingale systems. In principle I am against this method, especially if it is used in trading systems that don't have any other logic... Basically due to the spread those systems are doomed to fail, spread works here like 0 (green) in roulette.
It is a popular method of trading GBPUSD which is ranging since second half of 2010. Here is an example:
http://www.myfxbook.com/members/rsmereka/forex-hacked/218967 Adding also a screenshot - usually those systems are removed just after blowing up the account:
Description of three best three best martingale systems:
System 1: tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok BANG!
System 2: tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok,tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok,tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok, tik, tok BANG!
System 3: tik, tok, tik, tok BANG!
While I don't enjoy trading so much, I admire algorithmic trading: an endless challenge of making the best trading algorithm.
Wednesday, 31 October 2012
Thursday, 25 October 2012
Calling C# from MetaTrader
Some time ago I have discovered a way of linking C# DLL libraries with MetaTrader (I am using it on MetaTrader 4 but it should also work on MetaTrader 5). And I love this, because C#:
The method is well described here: https://sites.google.com/site/robertgiesecke/ It is just a Visual Studio Project Template that will modify the compilation options and expose managed methods for unmanaged calls. Short problem background: MetaTrader is written in C++ and allows linking external libraries with functions, variables, etc... If you create a library in C++, the code is compiled and the *.dll can be executed directly (so the *.dll is a set of instructions that can be sent to the CPU and executed). Linking C++ libraries with MetaTrader is extremely easy. However, in managed languages like C# or VB.NET, the code is compiled into an Intermediate Language (MSIL). This is then run by the run-time engine (.NET Framework) and translated into the machine code that is executed by the CPU. In general there are many methods of calling the managed code from unmanaged one (to name a few: C++/CLI wrappers or COM interop), but this one is definitely the easiest.
So how I am using C# libraries? I have a SQL Server database containing good quality 1-minute data for several instruments. And I use C# to execute algorithms against this data set. Example: In the current project I am working on I have completely moved the processing logic to C# through three functions:
C# Definitions:
MQL Imports:
I use the C# library in the following way:
- is much faster in running complex calculations than MT4 is,
- it allows to implement multithreading,
- provides all the flexibility of a modern Object Oriented Language.
The method is well described here: https://sites.google.com/site/robertgiesecke/ It is just a Visual Studio Project Template that will modify the compilation options and expose managed methods for unmanaged calls. Short problem background: MetaTrader is written in C++ and allows linking external libraries with functions, variables, etc... If you create a library in C++, the code is compiled and the *.dll can be executed directly (so the *.dll is a set of instructions that can be sent to the CPU and executed). Linking C++ libraries with MetaTrader is extremely easy. However, in managed languages like C# or VB.NET, the code is compiled into an Intermediate Language (MSIL). This is then run by the run-time engine (.NET Framework) and translated into the machine code that is executed by the CPU. In general there are many methods of calling the managed code from unmanaged one (to name a few: C++/CLI wrappers or COM interop), but this one is definitely the easiest.
So how I am using C# libraries? I have a SQL Server database containing good quality 1-minute data for several instruments. And I use C# to execute algorithms against this data set. Example: In the current project I am working on I have completely moved the processing logic to C# through three functions:
C# Definitions:
MQL Imports:
I use the C# library in the following way:
- When the Expert Advisor starts (MQL init function) I call the initDB function. What this function does, it will initialize the C# algorithm and load the data from SQL Server to memory (so the calculations will be placed fully in C# to improve calculations performance).
- Then I just pass some data from MetaTrader to getProbability function in C#. This will do all the maths, based on the most recent price data and settings received. It will return calculation results back to MQL and MQL will execute the trading logic.
- When the expert advisor will shut down, I am just calling the deInitDB to cleanup after the algorithm.
More information about what I am trying to achieve through this will follow...
Thursday, 4 October 2012
Historical data
I have spent some time looking for good source of 1 minute intraday data. While good quality forex data seems to be pretty easy to get, even for free (for example through Alpari or Dukascopy trading platform), it's much harder with other instruments.
I was interested in getting DAX futures history. EUREX, is selling DAX data, at 200 Euro per month for the tick data set. But I was able to find a decent quality 1 min data and I paid just 280 Euro ($400) for ca. 10 years 1-minute data. I tried a few other sources, but anything cheaper than that was just rubbish (with a lot of bad ticks or gaps which made it impossible use it for strategy testing of any kind).
There are a few vendors, I do not want to encourage or discourage you to use any particular one, but I tried TickDataMarket and TickData and was satisfied with both.
I was interested in getting DAX futures history. EUREX, is selling DAX data, at 200 Euro per month for the tick data set. But I was able to find a decent quality 1 min data and I paid just 280 Euro ($400) for ca. 10 years 1-minute data. I tried a few other sources, but anything cheaper than that was just rubbish (with a lot of bad ticks or gaps which made it impossible use it for strategy testing of any kind).
There are a few vendors, I do not want to encourage or discourage you to use any particular one, but I tried TickDataMarket and TickData and was satisfied with both.
Subscribe to:
Posts (Atom)


