High risk reward ratio strategy need EA

hello. ive been trading for close to 6 yrs and have done quite well, but im not

really a programmer so im looking at one of the systems i use but need to create an

EA so i can see how the strategy performs statistically on different timeframes and

also on 12 yr backtest. Im hoping someone with programming skills can help code

this one, its not complicated, infact it uses on 2 moving averages and the trade

setup is as follows. also see diagram (picture attached) for clarity.

:Setup:
6 EMA close with a SHIFT=1 (pink line). This shift value is very important. If this

EMA is above the 26 EMA close with SHIFT=0 (black dashed line) then when a candle

opens above the 6 ema , we enter a buy limit order at the 6 EMA line (blue bold),

with a stop loss 1 pip below the previous candle low (red bold) - this is shown on

examples A, B and C. Take profit can be any defined level. The reverse scenario

applies for Sell orders eg. at C. Include risk based money management or fixed lot

size option, and also include a trailing stop or breakeven.


Hi pipjsteve,

I don’t think it would work, as you would never be able to place the trade, as the market has already moved higher and the spread is against you too.

I will code it up just to see if I am right. My experience is that as soon as you use an EA all sorts of problems arise. But what the hell, you make your own luck in this world.

Get back to you later, Trader9.

Thanks 009. i appreciate your help. code it and i shall show you the best parameters for it . its quite interesting , its not 100 percent accurate , but the reward ratio is quite great.

Hi pipjsteve,

I have created an MT4 indicator of your trading method. If you add it to your chart with your EMA’s already on it should display a yellow arrow up or down at the EMA crossover point and a red or blue arrow at the pending order entry bar(s) for buy or sell.

Does this indicator agree with you trading methodology?

The zipped file is a MT4 .mq4 file so you will have to add into your indicators folder and then compile it in the editor screen before you can attach it to a chart. it will work all time frames and pairs.

High_Risk_Reward_Ratio_Ind.mq4.zip (1.67 KB)

I have also created an EA, but am having a few problems. When building a EA there are always more questions than answers. For instance if long did you want to reenter the market long again on a new long signal if the last trade was stopped out or wait for a short signal?

If long and and the market turns did you want to stay in the trade until your stop or profit target is hit or close the trade and place an order in the opposite direction?

The EA I have created has trailing stop, take profit and minimum profit settings. Do you need all this?

It trades either a percentage of your account or a fixed lot size.

I normally set up my EA’s to only trade on the new bar open. This allows me to place the initial stop, which I never move, as it is my maximum risk point.
I then I trail an out of the market stop that is only activated if there has been a close below it. So, a spike that passes through, but doesn’t close below my trailing stop doesn’t knock me out of the trade unless it hits my initial stop. In this way I avoid a lot of market noise. Hope that made sense?

Let me know how you get on with the indicator and if you want/need trailing stops etc. Tell me how you actually trade this setup so I can add it into the EA.

Regards, Trader9.

Hi pipjsteve,

Got the EA working, but it will need some fine tuning I expect. I only ran the strategy tester on H1 USDJPY results were not good. £240 profit on 1200 trades with a drawdown of £947 using 100 pip trailing stop, 105 pip target with a 45 pip min profit. Equity curve looked like the rocky mountains.

Probably I was not trading it as you would have done, as I need more info on the exact way you trade it.

I didn’t attach the EA as it probably wants more work and its your system and you may not want everyone getting hold of it.

If you send me a personnel message (PM) with your email address I can email to you direct.

Have a great weekend, Trader9.

Hi pipjsteve,

Ignore the last message, I had misunderstood your trading method and was using a BuyStop not a BuyLimit which you did put in your notes.

You are placing a BuyLimit order if the open of the current bar is above the 6 period EMA value which is shifted by +1. Your entry price is the 6 EMA value and your stop is the low of the previous bar.

You then hope to enter a long trade on a pullback to this level for a better entry long. This is the bit that I had not understood.

I finally get it. This should improve the results somewhat. I will get back to you next week.

Trader9.

Exactly what i need. Thats the idea. if candle opens above the 6ema then we set buy LIMIT at the 6ema line (shift = 1, means no repaint). thanks for the work i will be waiting for this one. once you,ve done it i will PM and give you the optimized parameters. thanks a million.

Hi pipjsteve,

You have made a bit of a fatal error I am afraid.

Take a long trade by shifting the 6 EMA by +1, you seem to think you can enter a pending order horizontally on the 6MA line on a new open above the 6 EMA line.

Unfortunately the 6 EMA line does not exist in the future. At the point that a new bar opens above the 6 EMA, the 6 EMA line is obviously below the new bar.

Example take your point A, the open above the 6 EMA. At this point the the candle could go in any direction and the moving average will follow until the bar closes. Only then on the next open can we say it opened above the moving average and then place our pending order. Repainting of the chart will continue until the bar is closed.

We can try and place the order at the previous open price providing it is below the current bid price plus a few pips margin set by your broker, which would probable end up on your red line not blue. And now your stop is way to close.

Most brokers won’t allow you to place trades or stops within 3-4 pips of the Ask price if going long or 3-4 pips of the Bid price if going short. I am with Alpari and I believe I cant place a trade within 8 pips of the current Ask or Bid price.

The EA is working but the pending orders are being placed as I described above and the stops are way to close and most trades never get entered into or get stopped out as the stop is too close.

I have only tried H1 USDJPY. I still have to make some additions to the EA so that if the pending order is not triggered then it is modified every time there is a new signal. This should help as at the moment it suffers with whipsaws in sideways markets and misses out on the trends.

Regards, Trader9.

No, it doesnt repaint on the current candle if the shift=1. do any backtest using a template with 6ema shifted. you will see. the candle opens , moves then closes and the ema position stays fixed. the part that is repainting will be for the next future candle.

Hi pipjsteve,

Book your holiday now, it is working and making a good profit.

For a long entry I used Open>FastMA and FastMA>SlowMA but it was to vague, as it could be a Bear or Bull bar and a Bear bar makes it harder to place the trade as the price has moved towards the FastMA.

So I added Close>FastMA and Close>Open and this did the trick. In order to make sure we get into a trending market, I constantly update the pending order values on every new signal if it has not already been triggered. This seemed to solve all the earlier problems.

I only tested again on H1 USDJPY, using data from 01/01/2013 to date (15 months) and made £1192.00 on 202 trades using a £1,000.00 account trading at 0.1 lot size and drawdown was only £199.00.

Using the same a £1,000.00 account trading at 2% on each trade made £14,207.00 and drawdown was £1,1204.00. £38,204.00 profit -23,997.00 loss. However, equity curve is a mess.

I did optimise by using TakeProfit = 220, TrailingStop = 135, MinimumProfit = 65 and I noticed the best EMA’s were 2 and 18 with no shift for this pair on a one hour chart for this dataset.

I will leave the real backtesting to you.

Using the MetaTrader strategy tester you will be able to test many scenarios.

External variables that you can change are:-

FastMA = 6; Fast EMA period.
FastMAShift =1; FastMA shift.
SlowMA=26; Slow EMA period.

TakeProfit = 100; Take profit value.
TrailingStop = 50; Trails stop by this value
MinimumProfit = 50; Starts trailing stop after this value.

PendingPips = 0; used to increase the distance from entry signal to pending order entry price.
Slippage= 3; Leeway used to prevent the dreaded re-quote when placing or closing an order.
StopPips=1; The extra pips added to the stop distance (You asked for 1 pip).

DynamicLotSize = false; If true then it uses a percentage of your account on each trade.
EquityPercent = 2.0; If DynamicLotSize = true then this is the account % used.
FixedLotSize= 0.1; If DynamicLotSize = false then this is the Lot size used.

MagicNumber=123; This number must be different for every pair and timeframe, as it is a unique order identifier if using the EA on more than one pair and multiply timeframes, I suggest a code.

Example :- EURUSD I code as 1 so the magic number for the M5 chart is 1005, the H1 chart 1060 and the H4 chart 1240 etc. GBPUSD I code as 2 so the M5 would be 2005 and the H1 2060 and so on.

CheckOncePerBar=true; I only trade on the open of a new bar, as I find that more flexible. For every tick change to = false.

PM me for the EA. Regards, Trader9.

great great to hear that. there are many ways we can optimize the values for differnt pairs and tf so we can get even better results im sure. i tried to pm you but seems i dont know exactly how to do that lol , im quite dumb hehehe. maybe you can try pm me, that would be better. many thanx and uh i think i might wanna book that holiday , for as long as the market is still in our favour lol

Hi pipjsteve,

I have just PM’d you with my email address. You may not be able to pm me as you have not made many posts? However, if you ever need to pm anyone just click on their name and you will be given many options and one of those options is to send an email.

I found a cut and past error in the short side code this morning as I noticed it had poor results when short. So it should now be even more profitable.

Also I noticed the stop is very close so I added a MinStopSize function that can be varied and switched on or off.

Regards, Trader9.

hello 009. i cant see the message. i suggest you just upload the ea here, for 48 hrs then you can delete it afterwards. im having trouble with the private messages thing. thanks

hi 009. i havent seen your message, if you sent it through the “send an email” link then chances are i wont see it, reason being that i last used the email address on that account a long time ago and i cant access it now. i will send a visitor message on your profile and give you a link to my functional email address we can communicate there.

Hi pipjsteve,

I have sent you the EA and and a second file for the includes folder to you by email.

Have fun and let me know how you get on.

Regards, Trader9

Thanks thanks. I got the files . i will definitely will be testing everything tomorrow morning, will let you know how its going.

thanks mate

How are you getting on with this strategy pipjsteve?

I think it is an excellent strategy and I was previously using something similar with a pullback to a 5ema shift1.

Hi pipsteve,

I have found a way to improve my EA’s by up to 50% and make them quicker to backtest using the MT4 strategy tester.

The trades will better reflect the market you are in by going long more often if the market is going up, or down more often if the market is falling.

I basically trade the four hour charts, as they seem the most profitable for my style of trading. I place stop orders above and below the market either using multiples of ATR(14) above/below the previous high/low or use period highs & period lows.

If my stop orders are not triggered and don’t become market orders during the current four hour period, then my EA updates the stop order entry price, take profit and stop loss values to reflect the changed market conditions when the new bar opens.

The first breakthrough I have already mentioned, is I allow my trades to complete their cycle. So if my BuyStop is triggered and I am long the market and there is a market move that triggers a SellStop on the same pair, I do not close the long, but allow both trades to work out. This proves to be more profitable over the long run as the new short position could have failed as a trade and stopped my long trade from going on to bigger profits.

Ok, improvement number two. I have moved my minimum profit and trailing stop code inside the once every four hour loop. So any move to break even or of trailing my stop only happens once every four hours on the new bar open.

This gives two benefits, the first is it protects your stop if the next four hour period is very very volatile and it also means that you can get good results using the strategy tester on “Open prices only”. Because if you then test using “Every tick” using the same parameters the results are very similar and you only need to make one quick check.

Basically this change quickly puts you in the “Ball Park” of best value parameters for your EA. You could then fine tune using every tick if you wish, but don’t over optimise.

Regards, Trader9.

Hi Trader,

Are you trading the idea posted by pipsteve?

Hi usuless23

In a word no, as I had turned it into an EA for Pipsteve. I find it relatively easy to create an EA and doing them for other people helps me to learn and just maybe their EA idea, is the Holy Grail system.

I had my own EA’s and as Van Tharp say’s you can only trade your own beliefs about the market.

Also I was not convinced that trending systems would work as well in the future as they had in the past. Post banking crisis and all the world turmoil and of course all those algorithms used by the big boys, turning the market into what I think is stability to instability and back again so I like to trade breakouts.

I was up to version V9 with Pipsteve V7 could open two trades at a time if the market was in a trend and V8 could put on 3 trades and manage them all independently.

However, you will have read my last post here about using a different technique to run my EA’s. So this morning I decided to modify V6 which was the single trade at a time system.

I ran it in Open prices only on EURJPY D1 data to get some “Ball Park” values for the parameters and then I watched the trading in visual mode and clearly the trailing stop was getting to close and got stopped out. Also the MinimumProfit (MP) and TrailingStop (TS) values were weird 40 and 5 pips.

To work properly they should be about the same value. Not much point in waiting until you are 40 pips up, then move your stop to break even then trail at 5 pips, as you are bound to get stopped out strait away. And the trailing stop was trailing way too close and being stopped out as the markets today are more volatile than they ever were.

The take profit was too close as well, cutting any winning trade short. I also thought that the long and short trades needed different parameters, so I have split them.

So I ripped the EA apart and moved the trailing stop code inside the run once every new bar code, so now the stop is only trailed once on every new bar, so that it remains outside hopefully of the current bars volatile moves. I also split the parameters for long and short.

I also noticed the initial stops were too close so I added a minimum stop size as multiple of the ATR(14), so now the minimum stop size is a multiple of the ATR (2 * ATR for EURJPY) or the last bars low, from entry point, whichever is greater. ATR(14) gives the average bar size of the last 14 bars and therefore it includes a certain amount of current volatility in to system and places the stop in a safe place.

The main advantage is that by only trading once per new bar you can use the MT4 strategy tester in “Open prices only mode” to roughly optimise and get some “Ball Park” values, it should then run in “Every Tick mode” for a final test and give similar results, which it does.

I have only tested on D1 data for EURJPY, Jan 2013 to June 2014 and the results are amazing.

Using a $1,000.00 account and $1.00 per pip over the eighteen month test period on EURJPY daily bars we get a profit of $3,892.04 on 63 trades, 11 shorts 63.64% win rate, 52 longs 94.23% win rate on tick data. Total drawdown $584.76.

Thats a total of 56 winning trades (88.89%) with an average win of $86.03 and an average loss 7 trades (11.11%) at -$132.24. And only one consecutive loss. Van Tharp would grade this as an excellent system as the expectancy is 0.47. The only let down is the opportunity is only 63 trades in 18 months.

However, I only tested on EURJPY and daily charts so you could use the strategy tester to find other pairs and timeframes that may be better.

The results were very good I thought, so I maybe trading this in the future. Thanks Pipsteve.

Regards, Trader9.