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 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 LastLowVar5 buy */Closes position if the price crosses the -1ATR and is trading aboveit in the next period/*

 

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.

 
leeb:
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.

 
Styex:
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.)

 

Thanks, I can hardly wait.

 

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.

 

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

Files:
 

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.

 

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!

Files:
 
Roger_Taum:
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

Files:
 
Styex:
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!

Nice! Just let me know if it's working as expected (as per rules in 1st post) and what logic should I incorporate into code.

All the best,

jonescu

Reason: