| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 Thanks! - Arthur Matteson |
|
|||
|
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? http://www.piptrader.com/export_data.asp - Arthur |
|
|||
|
Arthur,
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. |
|
|||
|
Quote:
- back to 2001 for 4 majors; - back to the beginning of 2004 of any others. Somebody posted in in this threadby link I need data for Metrader 4 It should be back to 2001 (if i remember). I did it for raff1410 because he wanted to develop something about two months ago. Last edited by newdigital; 09-14-2006 at 04:46 PM. |
|
|||
|
Quote:
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, Wally Just found the testing link: http://strategybuilderfx.com/showthread.php?t=15309 Last edited by Weasel; 09-22-2006 at 03:36 PM. Reason: Addition |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| testing EA ? | martym | General Discussion | 5 | 06-10-2007 05:58 PM |
| the ea I am testing | martym | General Discussion | 4 | 05-12-2007 04:04 PM |
| Need help with EA for testing | colnc | Post and compare Trades | 0 | 12-20-2006 07:50 PM |