ArtTrader v1.5, need help testing


Hi All,

I'm quite new to the whole forex biz. My friend's traded live with Oanda and had some success (he got me into this), but I found manual trading to be too emotional. The idea of expert advisors fascinated me, so I wrote a few of my own. The one included is the one that works the best so far. It's intended to work with a spread of 2.0 on EUR/USD (I plan on using FXDD) and is only meant to work on the H1 timeframe.

I've been programming for twelve years (I'm 22), so I just threw together this EA in about four hours. Its main goal is the simplest approach of trading: buy low, sell high. It basically scalps on trends of EMA 11 on the H1 timeframe, but buys/sells at the lowest/highest possible points. Over the course of the last two months (MT4 backtest), it makes 43.5% with one lot. The code with comments and adjustable variables is included, as well as the HTM and GIF results from MT4 (build 197, just got updated today). It wins 87% of the time in these last two months!

These results were actually published in Linux. I'm running Wine on Fedora Core 5 so that I can use Microsoft programs. Unfortunately, I can't see any menu item labels, and the optimizer won't work. But when I change my OS to Windows 2000, I can't simulate past a month ago. I'm very frustrated with MT4, and I even wrote a separate C program to simulate the less-successful ArtTrader v1.4. Am I doing something wrong? Why doesn't the "Use date" function work? When I try to select a year-span, it just sits there calculating but doesn't put through any orders. This EA needs all the ticks it can get because of the way it works; perhaps M1 data isn't available from a year ago in the simulator? Seems odd.

If someone who knows how to work MT4 (or even MT3) could put through a yearly simulation/backtest, that would be very helpful. Optimization is also strongly encouraged.

Technical comments:

- This program only works with one order at a time. Nothing complex occurs at all (no order modification). If other EAs are running, this program will not work properly. KISS principle.

- The current NUM_LOTS is 1.0. I found this to be a nice standard for testing. If anyone simulates, please use this lot size of 1.0 for easy comparison.

- EMA_SPEED is self-explanatory.

- I find that when big jumps occur, from news or whatnot, that it's best to ignore them because they're unpredictable. This is what the JUMP variables are for.

- STOP_LOSS is the intelligent order-ender. It waits MINUTES_END to check whether the current price is relatively high or low, if a loss is being incurred.

- EMERGENCY_LOSS is the stop-loss value passed to OrderSend.

- TAKE_PROFIT is also passed to the ordering function. It is the only way to end a positive order (and it seems to work well at 25 pips).

- SLOPE_SMALL/LARGE are derivative (dy/dt) limits of the EMA, with dy being EMA_new-EMA_old, and dt being one hour. The units are of course pips/hour. No orders will be entered if the slope is outside these values (positive or negative).

- MINUTES_BEGIN waits this many minutes to compare the current price with the high or low point of the current, incomplete candlestick.

- SLIP_BEGIN/END are used when entering/exiting orders, to measure the acceptable distance between the current price and the incomplete candlestick high/low price.

- If MIN_VOLUME is -1.0, no orders will ever be ended by the measure of volume. If it's 0.0, all orders end on the weekend (or at dead times).

- I don't know what to make of SLIPPAGE. It's there if you need it. It's the variable passed to OrderSend. The help gave 3.0 as an example, so I used it.

- When making the spread detect automatic, I accidentally put the (Bid-Ask) the wrong way and noticed a higher profit. I fixed the problem but added a variable to supplement this. The difference is +3.37% in two months with ADJUST=1.0 as opposed to 0.0.

From the code:

extern double NUM_LOTS=1.0; // How many lots to deal with (may be less than one)

extern double EMA_SPEED=11.0; // The period for the averager

extern double BIG_JUMP=30.0; // Check for too-big candlesticks (avoid them)

extern double DOUBLE_JUMP=55.0; // Check for pairs of big candlesticks

extern double STOP_LOSS=20.0; // A smart stop-loss

extern double EMERGENCY_LOSS=50.0; // The trade's stop loss in case of program error

extern double TAKE_PROFIT=25.0; // The trade's take profit

extern double SLOPE_SMALL=5.0; // The minimum EMA slope to enter a trade

extern double SLOPE_LARGE=8.0; // The maximum EMA slope to enter a trade

extern double MINUTES_BEGIN=25.0; // Wait this long to determine candlestick lows/highs

extern double MINUTES_END=25.0; // Wait this long to determine candlestick lows/highs

extern double SLIP_BEGIN=0.0; // An allowance between the close and low/high price

extern double SLIP_END=0.0; // An allowance between the close and low/high price

extern double MIN_VOLUME=0.0; // If the previous volume is not above this, exit the trade

extern double SLIPPAGE=3.0; // This is for the OrderSend command

extern double ADJUST=1.0; // A strange but functional imaginary spread adjustment


- Arthur Matteson


EA test

Hi Arthur,

I will try your EA. What pairs do you recommend ?

Also I see modeling quality of 58%. Try to get better quality data for backtests.


It seems to work well on EUR/USD. I think because it has the least spread, and a good variation per day. Feel free to try any others; you may need to optimize the ADJUST variable if the spread is not 2 pips. I really haven't tried much.

How would I get better quality data?

I did find a spot for some Forex data, but can it be imported into MT4?

- Arthur


go to alpari site and download M1 data it should give better modeling quality around 80 %

i will test this EA live next days


forgot to say this :don't trust mt4 backtest results,let it trade live on demo acc. for some time



I am not sure if this was your intention or not, but when you use "[0]", it means the current bar that is being formed. If you want to mean the bar just completed, you have to use [1] and for the one previous to that, [2].

Also, you have to think about using MagicNumbers and order symbols to count your open orders. Otherwise, it will be a pain in the behind to trade it live.

Good luck and thanks for sharing.

Sergey Golubev  
I improved it a bit. Here's v1.6.

Where did you get data for back to 2001, Foxxx? The Alpari data only covers to 2004. I would like to find as far back data as possible for all pairs, really.


- Arthur

One or two months ago I published the data:

- back to 2001 for 4 majors;

- back to the beginning of 2004 of any others.

Somebody posted in in this threadby link

It should be back to 2001 (if i remember). I did it for raff1410 because he wanted to develop something about two months ago.

I can't simulate past a month ago

Hi Arthur,

If the tester will function under Linux but will only go back a month or so, I would suspect that the test data isn't making it into the tester. There is a thread somewhere (I believe it is on this forum) regarding effective use of the MT4 testing module. I'll take a look and see if I can find it. Unfortunately the tester behaves differently depending on which version you are running.

Good luck,


Just found the testing link:


Off subject, but!!

Hi Mattes12,

This is off the subject, how are you running MT4 in Linux? Linux was my main operating system for several years before I started trading. I absolutely hate windoughs and MISS my KDE desktop. If you could give me a clue how you are doing this please let me know! Thanks!

See you said you're using wine. Does not work well. Was hoping you had dreamed up something different and maybe you will! Smiles to you!