Trend system with candlesticks filter

 

Hi,

I have been working on an EMA crosing system that does not trade on all crossings but instead uses the position of two emas to validate entry conditions on a candlestick formation.

This is:

If short term EMA > Long term EMA and a three black crows formation appears a buy market order is activated

If short term EMA < Long term EMA and a three white soldiers formation appears a sell market order is activated.

A stop loss and take profit are set as multiples of ATR and a trailing stop is also set as a multiple of ATR.

I think that performance could be greatly improved if entry is not made on market but with a pending stop order, but that order must be cancelled if the market does not go in our way, in say two bars, but I have not been able to code that condition...... Some help would be very appreciated here.

I have attached the code and the results on a mini account on IBFX.

Thanks for reading and I hope someone would be interested in this post.

PS:

I accept all criticism with humility, and please be as hard as you want, it is my first EA (I acctualy created only the Candlestick code and the stop, tp, and TS code, the rest is part of other experts i found online and integrated into my code,so if you see something you have seen before, that is the reason, thanks to all those coders who have posted)

 

Interesting

Good work, looks quite promising on some back-tests I ran. It seems like you may be on the right path, but of course there is much more work to do.

I have spent quite a lot of effort on really simple systems myself, and they can perform quite well in some situations. The problem is always that the market patterns change over time, and sudden changes can easily wipe us out.

I think your EA is a clever first effort, but it will need a lot of fine tuning before it would live 'in the wild'. Do you have further ideas to develop it ?

Thanks for sharing

 
 

Ma & 3 Crows

I am developing an EA for myself that uses pending orders. My philosophy is to place the pending order a couple of pips above the high/low of the buy bar. If the price reverses on the next bar, I adjust the pending order price up or down by one half of the sum of the bar's open and close. I continue this price reduction for additional bars that are going counter to the order signal. If the reversal closes below the EA or the SL then the pending order is deleted. Pending orders can be problematic if the price is briskly moving in your favor as some brokers do not provide the StopLevel amount so you have to "guess" where it is to generate the Pending Order Price

I looked at your EA and it needs the ability to handle 4/5 digit brokers and to also handle ECNs where the SL, TP must be placed through an OrderModify not on the OrderSend. Your EA should probably also handle both actual and pending orders.

 
Files:
 
nikorivera:
Hi,

I have been working on an EMA crosing system that does not trade on all crossings but instead uses the position of two emas to validate entry conditions on a candlestick formation.

........ removed for brevity .......

I accept all criticism with humility, and please be as hard as you want, it is my first EA

Sorry I forgot to say, I noticed you back-tested using only 'Openprices', the least accurate modelling method. I really think you need to use 'Every tick', at the very least, and aim for the best modelling accuracy if it is to mean anything.

I have done that with your EA using a fairly powerful VPS server I am trialling and the results are interesting but not an overall success. I read recently of an even better method using the Dukascopy data feed, where we could test using genuine Tick data, rather than the 1m & 5m averages, that can only achieve 90% accuracy. The true Ticks achieve 99%, but files get very large

I am re-running it on various periods to create files to post here. Of course back-testing is only an indication, and not proof of future ability. The market behaviour really has changed over the years and EA's that can cope in all those conditions are few and far between, if they even exist.

It seems likely that we need Ranging and Trending modules to ever get close to reliability, plus the code to detect those conditions. There are some good examples of how to do that built in to existing EA's, such as Blessings. However my tests with Blessings proved to me that it is not ready yet. It is a grid trading system, with an almost martingale progressive walk. Scary

 

Working, working, working

Hello everyone, thank you very much for al your feedback,

Tzuman, do you have any code written on the program you mention (pending orders) that you would like to share with the community.

Newdigital, thank you for the links, I am currently studying the information in the Volatility Expansion forum. The other links sent me to the elite section, I am not a member yet, so I cant see those links, but thanks anyway.

Ajarn, I will look into that, and let you know when I get some progress.

Have a great trading thay

 

Pending Orders, First Things First

Nikorivera: Before I can get to Pending Orders, I need to enable 5 digit quotes and ECN processing as I use FXCM currently. I will try to get these enhancements next week as I am currently busy on other projects. After that, we can address Pending Orders.

In the interim, think about an algorithm for determining the Open Order Price for a pending order. This price has to be at least "StopLevel" away from the Bid/Ask price. Mine is consider the bar high/low to be a resistance level and place the pending price beyond this resistance by a couple of pips and make sure it is beyond the StopLevel. My problem is FXCM doesn't provide the StopLevel so I have to SWAG it.

Talk to you next week

 

Trading Time?

I've made some initial changes and now I'm beginning to test but I need to know what the trading time means.

In the defaults, the trading time is set to start at 8 and end at 17, with the comments in code gmt-1 time. As many brokers use different server times, can you define the time of day the EA should trade relative to either London or New York times so the offset can be properly determined.

 

Trading Time

Tzuman:
I've made some initial changes and now I'm beginning to test but I need to know what the trading time means. In the defaults, the trading time is set to start at 8 and end at 17, with the comments in code gmt-1 time. As many brokers use different server times, can you define the time of day the EA should trade relative to either London or New York times so the offset can be properly determined.

Tzuman,

The expert was created to work only during 8 AM to 5 PM, and the comment reffers to the datafeed time configuration that I use, that is Interbank FX.

Happy good friday

 

Where are you

Hello Nikorivera:

Then can I assume you are trading only on London time?

I ran a preliminary test last night using M5 with usetradehours set to false e.g. trade all the time; one loser and 2 winners for about 2.9% profit, not bad. It seems that we should be moving the stop loss down faster so we can achieve at least break even, would not have helped the loser though. Also SL should be be compared to current OrderSL to prevent increasing it if the ATR increases.

What time frame do you use?

I will test it more next week and start the pending order implementation. By the way, if the sell had been a pending order placed below the low of the third bar, it would not have been filled, thus raising the profit to 4.2%.

How did you determine your ATR multiples, trial and error or back testing?

But First Things First. Let me test more early next week and by mid week release a system that will handle 5 digit brokers and ECNs properly as well as modifying the SL processing.

Reason: