Posts Tagged ‘MetaTrader 4’

Take screenshots at trade

August 21st, 2012

I’m kicking myself for not implementing this earlier (actually I did implement it a while ago, but didn’t start using it until a few days ago), so I thought I would share some code for once to help out anyone writing and optimizing their own MT4 strategies. I simply call this function after I have taken a position, which saves the current graph (including any information written on it) for later inspection. I have found that this greatly helps me analyse the trade afterwards.

extern int  ScreenShotWidth = 1200;
extern int  ScreenShotHeigth = 1000;
void TakeScreenShot(int ticket) {

string ScreenShotFileName = StringConcatenate(”Purple_EA_”,Symbol(),”_”,DoubleToStr(ticket,1),”.gif”);

if (WindowScreenShot(ScreenShotFileName,ScreenShotWidth,ScreenShotHeigth)) {

//WriteLog(”Screenshot taken: “+ScreenShotFileName);


else {

//WriteLog(”Screenshot failed: “+DoubleToStr(GetLastError(),1));



Just call the method with the ticketnumber of the trade. This will dump the current graph and all eventual indicators and visible objects to a screenshot.

Which is the best CPU for backtests?

August 21st, 2010

I just asked myself that question as its been a few days since I started backtesting with tickdata from Dukascopy. Even short runs take a lot of time… Optimizations of a few parameters can take weeks. I just aborted a optimization run that was supposed to  take 1800 hours (that is 11 weeks roughly).

So, naturally I started thinking that maybe it is time that my 3 year old Intel Q6600 is replaced by a faster part. I must say that it have performed absolutely excellent, especially since I’ve overclocked it to 3GHz all the time I’ve had it. It is a quad core CPU, but sadly MT4 is a single threaded application, so only one of them is used at a time. I usually solve this by running four instances of the same test with one of the parameters range cut in four, but it is a hassle. MT5 solves all this as it not only is able to use all available cores in the host system it is able to out-source processing to agents running on other computers. But reality right now is that MT4 still is the main platform, and it probably will remain so for at least another 6-12 months.

I’ve googled for benchmarks, but I can’t find any. Sure it is a niche, but I really expected at least some results for MT4. I thought surely someone had bought a new computer sometime and tested it by running the same backtest on both. I know I would, but it seems I’m alone in this. Can’t find any benchmarks for either MT4 or MT5.

Read more…

Excellent tick data for 100% backtests

July 22nd, 2010

I found a great (old) article about getting optimal data for backtests in MT4. I personally usually use history data from JadeFX because that’s the broker I, mainly, use scalping strategies at, but it is full of errors and rarely gives even 90% quality.

Check it out:

I’m gonna test this as soon as I get a hour or two over… IE hopefully on Saturday.

Alternatives to MT4?

January 1st, 2010

With the upcoming release of MetaTrader 5 I’ve actually started investigating alternatives to the good and old MetaTrader 4. Why, isn’t MT5 good you say? Well, after running the Beta for just a day basically, I can say that it feels almost the same as MT4 and that it probably is very good. MQL5 seems good, but why MQL4 isn’t still supported I can’t understand. It would have been nice being able to use old EAs and indicators. Unfortunately the strategy tester isn’t activated in the Beta, so I can’t test that yet, but it is said to be multi-threaded and able to test multi-asset strategies, good stuff. Also there’s a order depth function (and view) now, which makes MT5 much more equities-trader friendly of course.

There is a change to the way positions are handled that I don’t think should be enforced by the platform though, and this is my gripe with MT5. It seems the NFA really have scared the Russians at Metaquotes into submission, so there is no hedging possibilities and a strict FIFO order execution in MT5. This isn’t good for anyone I think, and especially not for us that run multiple strategies (EAs) on the same account. Also, grid traders like RoboMiner is effectively hindered (luckily RoboMiner have a different strategy for NFA brokers with today’s MT4 that should work with MT5).

I’ve mailed my brokers (Alpari UK, and JadeFX) with questions about their plans about the upgrade, and the possibility to stay with MT4 (or even run both in parallel). We’ll see what they say, if they know themselves. I would like to use MT5 for trading equities and futures, and I really think this is what MetaQuotes have been focusing on.

Hopefully I won’t need another platform, perhaps the non-NFA regulated brokers can get a different version with hedging and free order close order, but just in case I’ve started looking around a bit. I already have experience from the JFOREX platform used by DukasCopy (as used by FAP Turbo Evolution), but I never liked it. Also the minimum accounts at DC is $10000 and the minimum contract size is $1M. That is too much for me, so it isn’t a alternative.

Another quite popular product is the NinjaTrader (current version is 6.5, but 7.0 is in beta). I’ve downloaded and started fiddling with it. NT works with quite a few different brokers, including that I already have an account with. There’s also a few ECN brokers like PFG and MBT. First impressions is that it is a good product, not quite as intuitive as MT4/5, but very manageable. The scripting language seems great.

So, is there any other alternatives?  I’m looking for free platforms (or at least platforms that the brokers pay the fee for) with small deposit limits ($1000 or so) and regular lot sizes (0.1 lot for ECNs and 0.01 for bucketshops). Of course it has to be possible to run automated strategies. Any tips? :)

Spread monitor

July 1st, 2009

I started thinking about a web application today that would publish the spreads of the top MetaTrader 4 brokers both in real time and with historical data. My idea was to open accounts at the interesting ones and run a small EA that recorded every tick to a database for further analysis by the web application. So I did a google search of course. It has been done before, partly.

Check it out, it is quite nice:

If I were to go ahead with my application anyhow it would include more bells and whistles. Most notably it would have spread history. I really would like to see the average spread over a definable time (like the Asian session) and a histogram of the distribution and so on. It would also be nice to see the rollover costs on the pair (some brokers take much more in swaps to be able to afford lower spreads). Also I would like to see some other brokers, like and CMSFX. But this one will do for now :)