Category Archives: MetaTrader 4

Metatrader Spread Recorder Indicator

forex spread recorder

Hi everyone. I just came across a neat metatrader 4 indicator that records the spread history of any currency pair you choose. Basically the way it works is you attach it to the chart of any given currency pair you prefer and it will record to a file every change in that currency pair’s spread (difference between bid and ask) until you tell it to stop recording.

This can be a really useful tool to keep an eye on your broker if you suspect that they’re doing something fishy like artificially raising the spread at key times during specific trading sessions, or it can of course be used as a mere curiosity and research tool.

For me this indicator is most useful in finding whether a particular broker is well suited for the Asian session scalper EAs that I use.

You can get this indicator by visiting the thread I created on the Forex Nirvana forum. You have to register to download the indicator, but worry not, the registration process is really quick and easy. Here is the link you need:

http://www.forexnirvana.com/f16/metatrader-spread-recorder-indicator-2159/

Hope you find this post useful!

Cheers,

Alan

Forex News Calendar MT4 Indicators

Hi everyone. I’d like to share with you two very useful indicators that show you the upcoming forex news releases. One is called FFCal and the other Plot News (version 3.0 – last and final release).

Install instructions for Plot News:

1. Download and unzip the News v303.ZIP file into your MT4 folder, unzipping the files within to the relevant sub-folders, and overwriting any existing files of the same name.
2. Restart MT4.
3. Run the Calc Timeshifts.EX4 script if you wish to have the time offsets calculated automatically for you.

For further instructions, additional information, screenshots, release history, etc, please read the ‘Operating instructions’ document (it’s in the ZIP file).

OR you can run the automated install program located in the NewsSetupv310.zip file.

Install instructions for FFCal:

Copy the FFCal.mq4 file into your MetaTrader 4 “indicators” directory, restart MT4, attach it to the chart.

In order to use it, you need to turn on DLL Imports in your Metatrader platform options, because it calls a DLL to get your timezone, as well as another to read the ForexFactory web page to get news information. (Be aware it will write out .XML files to your expert/files folder).

This is how one of these forex news calendar indicators looks like when attached to your MT4 chart:

forex factory calendar

You can find them both over at the Forex Nirvana forum:

http://www.forexnirvana.com/f16/forex-news-calendar-indicators-2109/

Enjoy!

P.S. You have to register for the forum in order to download the files attached to that forum post.

How to disable ‘Auto-Update’ in MT4

metatrader

Edit: It seems starting with build 482 the makers of MT4 (MetaQuotes) decided to put the platform update code right in the MT4 executable program itself so the platform now updates itself AUTOMATICALLY. I find this to be a bad idea and no doubt many of you do as well. I can go into a few reasons why, but I shall save that for later. As far as I know there is no way to disable this and prevent the platform from automatically updating (and thus restarting) itself. If I find something I will post an update here or in a new post.

Hello fellow traders.

I’m not sure how many of you have wondered if there is a way to get rid of MT4’s automatic auto update notification, but if you wish to permanently disable it I have found a solution. The most common reason I can think of why anyone would wish to do this is to ensure that your EA or backtesting platform is always running a specific version of MT4. This could be necessary for compatibility reasons or maybe you just don’t want to be bothered every time you load up the platform.

There is of course a downside to disabling the auto update feature. The main negative point is that you’ll never receive the latest bug fixes and security fixes that get incorporated into newer version of MT4. If you stick with one version forever you’ll have to live with all the bugs and potential problems that particular version of MT4 has.

But if this is something you are sure you wish to do, here is how you do it:

1) Open up the folder where you installed the MetaTrader 4 platform (typically it is located in c:\program files\)

2) Find a file called LiveUpdate.exe

3) Rename that file. It can be any name just make sure you don’t rename it to something you won’t recognize later. For example, I renamed mine to “LiveUpdate.exe-” (without the quotes obviously)

This will permanently disable MT4’s auto -update feature. Later on if you wish to upgrade the platform to the latest version available from your broker just rename the file back to LiveUpdate.exe and restart the platform.

That should do it!

Alan out.

Cheers!

How MT4 Backtesting Modeling Quality Is Calculated

Hi everyone. Today’s post is sort of an educational informational tidbit for all you MT4 junkies out there. One of the somewhat obscure questions I see on various forum is by what formula is the modeling quality calculated by the MT4 backtester. I’ve got the answer, and here it is:

ModellingQuality = ((0.25*(StartGen-StartBar) + 0.5*(StartGenM1-StartGen) + 0.9*(HistoryTotal-StartGenM1)) / (HistoryTotal-StartBar))*100%;

where:

  • HistoryTotal – the total amount of bars in history;
  • StartBar – the number of bar with which the testing was started. Modeling starts at at least 101st bar or the bar corresponding with the initial date of test limits;
  • StartGen – the number of bar with which the modeling on the nearest timeframe started;
  • StartGenM1 – the number of bar with which the modeling on minutes started;

at that:

  • The distance between the beginning of modeling of databases for the nearest timeframe and the beginning of modeling on the nearest timeframe data has a weighting factor of 0.25;
  • The distance between the beginning of modeling on the nearest timeframe data and the beginning of modeling on minutes has a weighting factor of 0.5;
  • The distance between the beginning of modeling on minutes and the end of history data has a weighting factor of 0.9;

The following colors are used in the color diagram:

  • Lime – modeling on minutes
  • Deeper green colors show modeling on large timeframes
  • Pink color – pure fractal modeling of the databases of smaller timeframe
  • Gray color – modeling limitation by date

From the formula you can see, that 90% is the maximum modelling quality possible. However if you give the backtester BETTER (higher quality) data such as raw tick data you can increase the modeling quality to 99%. Essentially the MT4 backtester interpolates price data from M1 chart data. If you give it TICK DATA it naturally has MORE data to work with and hence the accuracy of your backtest will increase.

I’ve got a post that teaches you step-by-step how to get 99% modeling quality. You can check out that post over here:

http://alansforexblog.com/2010/06/14/metatrader-backtesting-how-to-get-99-modeling-quality/

This method however does have some limitations. One that comes first to mind is that due to a file size limitation with MT4’s backtester you can run a backtest only is 1 to 2 year chunks. See the comments section of the above link for details.

Ok, I’m out.

Cheers,

Alan

MetaTrader Backtesting – How to Get 99% Modeling Quality

Greetings everyone!

In today’s post I’m going to show you how you can get 99% modeling quality when backtesting using MT4’s “Strategy Tester.” If you’re a MT4 backtesting veteran you no doubt know that using regular M1 historic data the highest modeling quality you can get is 90%, but what you may or may not know is that the accuracy of your backtests can be pushed even higher, BUT you need raw tick data.

How does one obtain such tick data? Well, I asked myself that very same question, and I’ve looked everywhere for a free source of historical forex tick data and after extensive searching I found it. The only problem is that the tick data is not readily usable by MT4 and as such requires a rather elaborate process of conversion and also a few other tricks to force MT4 to use the converted tick data. That’s where this tutorial or “how-to” comes in. So pay close attention as you MUST follow each step precisely.

You may be asking yourself why would one want to achieve a higher modeling quality level. The answer has to do with scalping. When backtesting an expert advisor that does not attempt to scalp the market the default MT4 history data provides an acceptably accurate level of simulation. However when you’re trying to backtest a scalping EA even the slightest variation in the price feed can strongly affect performance.

UPDATE: previous content removed. If you want the full tutorial you can find it on the following website:

Birt’s EA Review website

Happy backtesting everyone!

Cheers,

Alan

Forex Megadroid Backtest on Dukascopy Tick Data – 99% modeling quality

forex-megadroid.jpg

Hi everyone. I hope you’re all managing to make pips in this rough market. I’ve been rather busy lately so I haven’t had much time to update this blog. Among other things I’ve been rather busy working on and backtesting expert advisors (forex robots for the uninitiated.) I’ve been struggling to get my MT4 modeling quality beyond the max 90% capable with standard MT4 history data and I finally succeeded thanks to Dukascopy.

I found out that Dukascopy offers high quality tick data for free – thanks Dukascopy! After the rather extensive work converting the tick data to .CSV format and then that to the .FXT format necessary for the MT4 strategy tester you would not believe how joyous I felt when I first say the “99% modeling quality” when I ran my first backtest. Oh, by the way, I will post a “How-To” so you too can get this setup.

Now you may ask what does this have to do with Forex MegaDroid. Well, you see the first thing that came to mind when I finally got the history data all setup and ready for use was why not backtest one of my favorite EAs, which so happens to be Forex MegaDroid. This hard working EA has been consistently making money for me on two live accounts, but a bit of doubt hit me when someone posted on the Forex Nirvana forum a few rather nasty backtests of Forex MegaDroid trading from 2009.03.01 to 2010.03.01 (here is a link to the actual post).

I wanted to know if with better history data I’ll get the same results. Sadly though I could not get the Dukascopy backtest to run all the way to 2010 03 01 🙁 I don’t know whether it’s cause I did something wrong when I setup the Dukascopy tick data for MT4 or if it’s because of gaps in the tick data, but at best the backtest runs only from 2007 04 05 to 2008 03 05. I’m hoping that later on in the future I’ll be able to get more recent tick data working, and if I do I will backtest MegaDroid yet again and see if live account performance is equivalent to the backtest. But for now here is my backtest with proudly and painstakingly achieved 99% modeling quality:

Profit factor: 2.75
Expected payoff: 35.94
Maximal drawdown: 1753.29 (12.57%)
Relative drawdown: 12.57% (1753.29)
Short positions: (won %) 71 (94.37%)
Long positions :(won %) 60 (96.67%)
Profit trades: (% of total) 125 (95.42%)
Loss trades: (% of total) 6 (4.58%)

As you can see the results are very good but since I could not backtest the period showed in this forum post I can’t reassure you nor myself that MegaDroid won’t behave as in the backtests shown on that thread.

For now though live account performance continues to be satisfactory for me, but as you should know past performance does not guarantee similar future performance. Anyways, I’ll keep you up-to-date on the performance of my live Forex MegaDroid accounts. Wish me luck.

Time to wrap up this post. Thank you for your attention, and I wish you profitable trading, be it manual or (as in my case) with forex robots.

Cheers,
Alan

Analyzing MetaTrader Strategy Tester Backtest Results

Okay, so you’ve set up your history data and completed your backtest using Metatrader Strategy Tester. Now let’s look at the results.

There are four tabs to look through: Report, Graph, Results, and Journal

Report:

This is the meat of the backtest. All the statistics of the backtest are displayed here.

• Bars In Test – Displays the depth of the history on which the modeling was based.

• Ticks Modelled – Displays the size of the modeled sequence. Every record of the sequence represents the bar state (OHLCV) at one or another moment. Different bar states can be modeled depending on the timeframe, modeling method, and presence of history data from smaller timeframes within a bar.

• Modelling Quality – Calculated according to the following formula. This should be 90%. If not, read the article on downloading and setting up history data.

ModellingQuality = ((0.25*(StartGen-StartBar) +
0.5*(StartGenM1-StartGen) +
0.9*(HistoryTotal-StartGenM1)) / (HistoryTotal-StartBar))*100%;

• Gross Profit – The summed up profit for all profitable transactions;

• Gross Loss – The summed up loss for all unprofitable transactions;

• Total Net Profit – The Gross profit minus the Gross loss.

TotalNetProfit = GrossProfit – GrossLoss

• Profit Factor – Profit factor, shows the ratio between gross profit and gross loss. The larger this number is, the better.

        ProfitFactor = GrossProfit / GrossLoss

• Expected Payoff – Calculated as follows:

        Expected Payoff = (ProfitTrades / TotalTrades) * (GrossProfit / ProfitTrades) –
(LossTrades / TotalTrades) * (GrossLoss / LossTrades)

• Absolute Drawdown – Absolute drawdown is the difference between the initial deposit and the smallest value of balance within testing:

        AbsoluteDrawDown = InitialDeposit – MinimalBalance

• Maximal Drawdown – The highest difference between one of local upper extremums of the balance graph and the following lower extremums:

        MaximalDrawDown = Max of (Maximal Peak – next Minimal Peak)

The rest of the statistics are pretty self explanatory, so we won’t waste time defining those. For more information on this, visit Metatrader’s website on backtesting

Graph:

This is pretty obvious, it is a graph of the Expert advisor’s trade results. The green lines at the bottom mark the lot sizes.

Results:

This tab displays every order placed with the running total of your account balance.

Journal:

This displays any errors and status messages.

Original article source: The Trade Machine (c)

http://thetrademachine.com/blog/2009/10/02/analyzing-backtest-results-in-metatrader-strategy-tester/

MetaTrader Optimization

Metatrader’s Strategy Tester allows you to optimize your expert advisor to find the most profitable settings for the multitude of possible input variable combinations. You can optimize an expert advisor on a specific chart for a specific time period to find out which input values produced the highest returns and lowest drawdown.

However, it is important to remember that you should not over-optimize. You may get amazing results with a specific input combination, but because the values are so constrained, you probably won’t see results like that in the future. When optimizing an expert advisor, remember to use your head and think about why you are getting the results you are. Was it from one huge winner that you are unlikely to see in the future? Or did it win many times, making it a plausible trade setup for the future.

Don’t forget, you need to have high quality minute data for optimization to be worthwhile. See the article on setting up your metatrader history data.

How To Optimize – Step By Step

To get started optimizing your expert advisor, open Strategy Tester. If you are new to backtesting, read the article: How to Backtest in Metatrader

Select the Expert Advisor from the pull down menu. Choose a currency Symbol and Period. Select Every Tick for Model. Check Use Date and select a time frame that you have high quality minute history data for. Finally check the box next to Optimization.

Next, click on the Expert Properties button on the right. Select the INPUTS tab to enter the range of values you will optimize for. The Start value is the lowest value that you start from. Stop is the highest. And Step is the increment that you step through the range.

For the TakeProfit value, you can see that we start at 50, step through at 25, and stop at 300. This will test every value inbetween 50 and 300 in a 25 increment. So, 50, 75, 100, 125, all the way up to 300. The same idea applies to the other variables.

The checkbox on the left must be checked to optimize for that variable. Otherwise, it will use the regular Value.

When you’re finished entering your input values, click OK. Now we’re ready to start the optimization. Click the Start button on the bottom right of the Strategy Tester window. The backtest may take minutes or hours depending on how many values you are optimizing for. You may want to choose a larger increment Step value or a smaller range if it is taking too long.

After the optimization has completed, select the Optimization Results tab to look through the results. You can sort by the values at the top. Select Profit to view in order of highest returns, or Drawdown to see which values had the least risk.

Original article source: The Trade Machine (c)

http://thetrademachine.com/blog/2009/10/08/metatrader-optimization/