Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-10-2009, 09:32 PM
Junior Member
 
Join Date: May 2009
Posts: 15
Styex is on a distinguished road
ATR Bound EA

So I have been trading for a few years now and finally decided to give a shot at developing my own EA. I have taken some lessons post around various forums and have done some VBA in the past, but know on my own I will have a lot of trouble coding my first EA.

I was hoping that I could get assistance with the syntax, of the system and some help tweaking the system once its done. I know its a lot to ask for, but from what I have seen on these forums, some of the posters are very friendly and helpful.

Basically the strategy of the EA is based of this article:
How to Use Average True Range for Short-Term trading

I took some time to write up what is to my understanding the variables and the conditionals that will be used in the EA version. I stated the default setting, as well as the user definable ones, UD = user definable.

Variables
*ATR = Average True Range indicator for 14 periods (UD)
Var1: Moving Average (UD)
Var2: Var1 + 1*ATR
Var3: Var1 + 1.5*ATR
Var4: Var1 - 1*ATR
Var5: Var1 - 1.5*ATR

Trading Conditions
**Long Position**
//Entry
If positions open = 0 // only 1 position should be open at a time

Open Buy: If Var current > Var -1 period > Var -2 period //Moving average slope is positive, suggestion on a better indicator are appreciate

If open < Var1 && Close > Var 1 //Crosses moving average from below

Enter Buy

//Exit
If close< Var 1 sell //price closes below MA sell
If current=> Var3 sell //price touches target profit of 1.5ATRs
If current=< Var4 sell //price hits stop of -1 ATR
If LastHigh>Var3 && Current<Var3 sell */Closes position if the price crosses the 1ATR and is trading below it in the next period/*

**Short Position**
//Entry
If positions open = 0 // only 1 position should be open at a time

Open Sell: If Var current < Var -1 period < Var -2 period //Moving average slope is negative

If open > Var1 && Close < Var 1 //Crosses moving average from above

Enter Buy

//Exit
If close> Var 1 buy //price closes above MA
If current<= Var5 buy //price touches target profit of -1.5ATRs
If current>= Var2 buy //price hits stop of 1 ATR
If LastLow<Var4 && Current>Var5 buy */Closes position if the price crosses the -1ATR and is trading aboveit in the next period/*
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 06-10-2009, 10:40 PM
leeb's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 368
leeb is on a distinguished road
Useful tool for you

Hi,

The link I have posted below is a free tool which automates building your EA, just select the buy and sell criteria and it will generate the code for you.

Expert Advisor Builder for MetaTrader 4

Hope that helps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 06-10-2009, 11:24 PM
Junior Member
 
Join Date: May 2009
Posts: 15
Styex is on a distinguished road
Quote:
Originally Posted by leeb View Post
Hi,

The link I have posted below is a free tool which automates building your EA, just select the buy and sell criteria and it will generate the code for you.

Expert Advisor Builder for MetaTrader 4

Hope that helps.
I tried using site before, and although it has some helpful parts, overall it was unable to create the EA I am trying to build. Thanks for the suggestion tho.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 06-11-2009, 08:06 AM
Junior Member
 
Join Date: Oct 2006
Posts: 5
jonescu is on a distinguished road
Quote:
Originally Posted by Styex View Post
I tried using site before, and although it has some helpful parts, overall it was unable to create the EA I am trying to build. Thanks for the suggestion tho.
I can code the EA for you...I'll post it later on...

First version will incorporate only the basic rules (as you stated in 1st post), after that we can incorporate additional rules (MM, stop loss trailing, etc.)

Last edited by jonescu; 06-11-2009 at 08:11 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 06-11-2009, 04:42 PM
Junior Member
 
Join Date: May 2009
Posts: 15
Styex is on a distinguished road
Thanks, I can hardly wait.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 06-11-2009, 08:55 PM
Junior Member
 
Join Date: Jul 2007
Posts: 19
Roger_Taum is on a distinguished road
Hi Styex,

Do you have an indi which displays the channel as per the article? Or if it is possible to be done through the offset and level options of the MA indi, how it can be done? Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 06-11-2009, 10:49 PM
Junior Member
 
Join Date: Oct 2006
Posts: 5
jonescu is on a distinguished road
Styex,

Here is the first version, very raw but I think it's good enough to test it and make proposals for improvements and/or report bugs.

Few questions:
- trailing stop or not? in case you want TS you just have to comment out lines 66, 67, 76 and 77
- same question for trailing TP - it's adjusted during trade or remain fixed during entire trade?

Best regards,
jonescu
Attached Files
File Type: mq4 ATR_Bound_EA.mq4 (3.5 KB, 65 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 06-12-2009, 12:00 AM
Junior Member
 
Join Date: May 2009
Posts: 15
Styex is on a distinguished road
testing it out now.

The ATR lines should act as a form of trailing stops and profits, but i will tweak the system around a little. Will let you know what the results are like.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 06-12-2009, 12:59 AM
Junior Member
 
Join Date: May 2009
Posts: 15
Styex is on a distinguished road
Alright I have a few minutes to write a quick update. So far we have a great foundation for this system and only a few things need tweak, I'll discuss that later.

But on the bright side, even as a first draft, the system was able to be profitable. Attached are the two equity curves from the back testing used on the EUR/USD using a daily time frame. I tweaked the second one changing the take profit to 1ATRs which improved the winning %. I will be doing some more tweaking and refining much later tonight, but for now we are off to a great start.

Cheers!
Attached Images
File Type: gif EURUSD1ATR.gif (10.0 KB, 285 views)
File Type: gif EurUSD15ATR.gif (9.5 KB, 280 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 06-12-2009, 01:58 AM
Junior Member
 
Join Date: May 2009
Posts: 15
Styex is on a distinguished road
Quote:
Originally Posted by Roger_Taum View Post
Hi Styex,

Do you have an indi which displays the channel as per the article? Or if it is possible to be done through the offset and level options of the MA indi, how it can be done? Thanks.
Here is the Indicator I used
Attached Files
File Type: mq4 ATR Channels.mq4 (4.1 KB, 46 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT. The time now is 10:26 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.