ADX and EMA Inside Period system

 

Hi everyone,

I just read the MQL4 guide a couple weekends ago and designed my first EA.

Anyways, here's my first EA: I don't know if it's a profitable system or not, but the results of my EA back-test don't match up with some manual back-testing I did. My manual back-testing shows the system is valid, and I know there are two filters I wasn't able to figure out how to program but I'll get to that after I explain everything. (I attached a text file with the code in it).

Here's the basis of my system:

Initial setup:

15m time period

If it's between 200 and 1400 EST.

If ADX is greater than 20.

If last bar's [1] range is less than the previos bar's [2] range. (Inside Period).

If last bar's [1] range is less than 7 pips.

Conditional setup A:

If 20-period EMA is up.

If Bid is greater than last bar's high [1] (I'm assuming the charts show Bid only... is that right?)

Buy at ask price with stop loss at one tick below last period's low.

Conditional setup B:

If 20-period EMA is down.

If Bid is less than last bar's low [1].

Sell as Bid with stop loss one tick above last bar's high+ask.

I want to set the take profit at a certain Risk:Reward rate. In my back-testing I found that when the Inside period's bar is less that 5, a 3:1 reward ratio is good. (a 30 pip limit order (5(range) + 3(spread) + 2(SL and entry))*3=30).... I don't think I programmed that correctly in my code though.

First question:

Am I using the right code to initiate the trades? Did I correctly use the highs, asks, etc.?

Second question:

My time filter doesn't seem to work. Am I doing this correctly?

Third question:

I only want the trades initiated ONE PIP above last bar's High+ask. I think my current code will initiate trades if prices gap above this price. How do I fix this?

fourth question:

I think this is the biggest error in my code: I don't have a filter for when the 20-EMA reverses but the ADX is still over 20. I would ALSO like to see how this system works if the 20-EMA reverses, the ADX goes down (but not lower than 20) and then goes back up, so MAYBE we could filter out trades when the ADX is down-trending, but then again this might filter out many profitable trades). If I could get some help on the coding, I would be fine experimenting on these different factors.

From my manual back-testing I think I may have a profitable system here, so any help would be appreciated.

Thanks in advance!

Jason

Files:
ipadxema.txt  5 kb
 

Any answers or input??? Did I explain everything okay? Is it easy to understand the basis of the system?

Basically we're looking for a breakout from a range contraction in an already trending environment.

 

Hi jargall, thank you for your post. Just be patience for couple of days, maybe people already gone to easter holiday. All the best for everyone

Reason: