Forex Factory (https://www.forexfactory.com/)
-   Platform Tech (https://www.forexfactory.com/forum/69-platform-tech)
-   -   Need guidance to improve my Trend Riding EA (attached) (https://www.forexfactory.com/thread/1009013-need-guidance-to-improve-my-trend-riding-ea)

kasinath Jun 28, 2020 10:07pm | Post# 1

2 Attachment(s)
TLDR:
I've been working on an MT4 EA that compares many trend trading strategies (using many indicator combos). I'm looking for guidance on how best to improve my approach.

Background:
I wrote software for 15 years but haven't written code in the past 6 yrs. I got back into coding 3 months ago to write MT4 robots when I realized I could do it easily, even though I had no prior trading experience.

My Ultimate Goal:
To have a collection of EAs with winning indicator combinations that successfully trade trends with little to no human intervention.

Work done so far:
I've created a trend 'rider tester' that

  1. Allows you to mix and match about a dozen different trend detection methods (eg BBands + Stochastic, MAs, etc).
  2. Places an order when there is confirmation across all the selected methods,
  3. Uses dynamic lot sizing based on % risk (of balance or equity),
  4. Sets a trailing stop loss that kicks in once profit is locked in.


Success so far:
I ran an optimization on M30, for EURUSD, from Jan '16 - Dec '19, and found the Alligator+RSI has the most success (at least the way I coded it), when run against Dukascopy data from tickstory. You can see the backtest result in the image below, and I've attached a set file if you want to see it in action, or DEMO trade it (i.e. with a demo account ONLY). My settings here are super aggressive (50% of acct balance), and take the account from $10K to $1.2M in 4 years)


Guidance Needed:

  1. What is a better way to set initial stop loss?
    My initial stop loss is massive (3400 points), compared to my profit trigger (100 points). I would love to reduce this to further increase gains, but the optimizer shows this is the sweet spot. I have heard that using Average True Range can help, if you multiply it by a constant, but none seem to work well. (( You can try this in the 'experimental settings' ))
  2. How best can I place multiple orders when a trend is detected?
    I tried some logic for 'duplicating winning orders' : when an order locks in a profit, clone the order, but with a smaller stop loss. This does not work well. (( You can also try this in the 'experimental settings' ))
  3. Whats a better exit strategy I could use?
    You may notice that most orders get in and out pretty quickly, even though there is more trend to be ridden. I am thinking of leaving it this way, but I cant help but feel there is a way to exit later for higher profit, while maintaining high win rate. I have heard using heiken ashi might be good; just watching for color change. I may try this next.
  4. Any Other Feedback Welcome!
    There are a lot of smart people out there... many on this forum Please feel free to spot out any issues / inefficiencies. I am new to this, so I am sure there are many little things I have overlooked that could make this better.


Thanks in advance!

Note:
Unfortunately I am not at liberty to share the source code here, but i hope this tester EA is a helpful contribution to the community
the-trend-rider-tester.zip
Click to Enlarge

Name: super-aggressive-gator-rsi.png
Size: 14 KB


kasinath Jun 30, 2020 5:14am | Post# 2

So... this thread had replies restricted. Removed that.

Hopefully there will be some replies now

Cerugo Jun 30, 2020 9:26am | Post# 3

TLDR: I've been working on an MT4 EA that compares many trend trading strategies (using many indicator combos). I'm looking for guidance on how best to improve my approach. Background: I wrote software for 15 years but haven't written code in the past 6 yrs. I got back into coding 3 months ago to write MT4 robots when I realized I could do it easily, even though I had no prior trading experience. My Ultimate Goal: To have a collection of EAs with winning indicator combinations that successfully trade trends with little to no human intervention....
Hello,
I checked your EA and you have the same problem I had with mine. It opens a trade at the point of pullback and you loss the the trade because of this. I solved this with pending orders. For JPY pairs 79 pips and 45 for the others and 5 days. Sometimes we loss entries, I do not care. You did a great job with this tool

kasinath Jun 30, 2020 9:59am | Post# 4

{quote} Hello, I checked your EA and you have the same problem I had with mine. It opens a trade at the point of pullback and you loss the the trade because of this. I solved this with pending orders. For JPY pairs 79 pips and 45 for the others and 5 days. Sometimes we loss entries, I do not care. You did a great job with this tool
Thanks a lot, Cerugo. I spent many sleepless nights working on this so it's great to hear someone find it valuable.

I like your suggestion about using pending orders. I was also thinking about using pending orders, maybe using buy stops and sell stops instead of market orders. I tried it once briefly but removed the code without fully testing it.

I will bring back that functionality and try it again.

Thanks!

Pip Wolf Jun 30, 2020 8:41pm | Post# 5

Kasinath hi. I will test your EA. I am also working on a trend following system, but plan to use 5 min chart. Might work on 15 up to 30 minutes. The indicators i use is ones i not used to, but they are non-repaint indicators. During testing there is ups and downs like most results. Will place my indicators with explanation. You maybe can code them accordingly. I am very positive it will be profitable. Must also only trade during certain hours.

kasinath Jun 30, 2020 10:47pm | Post# 6

Kasinath hi. I will test your EA. I am also working on a trend following system, but plan to use 5 min chart. Might work on 15 up to 30 minutes. The indicators i use is ones i not used to, but they are non-repaint indicators. During testing there is ups and downs like most results. Will place my indicators with explanation. You maybe can code them accordingly. I am very positive it will be profitable. Must also only trade during certain hours.
Thanks for your reply! I had thought about trading during certain hours, but haven't fully explored what logic to add.
I'm assuming you can still close trades outside of the designated hours, if conditions are met, but you just shouldn't enter new ones.

Will explore.

Cerugo Jul 1, 2020 7:13am | Post# 7

{quote} Thanks for your reply! I had thought about trading during certain hours, but haven't fully explored what logic to add. I'm assuming you can still close trades outside of the designated hours, if conditions are met, but you just shouldn't enter new ones. Will explore.
Hi Kasinath, After many days and weeks of working, I found that it is better to work with a good indicator instead of timing the orders. The best for me is Chaikin Money Flow. It will filter your sideways and spreads. For pending orders, I prefer Limit orders because I go with the pullback.

RedLineFred Jul 1, 2020 8:59pm | Post# 8

Suggest you research the topic of "skew" and how this relates to trading.

What you want is a system that delivers positive skew.

Positive skew means that your average winners are greater than your average losers. This will deliver the better equity return in the long run.

Your system has a very negative skew, which over time will lead to ruin.

kasinath Jul 2, 2020 2:56am | Post# 9

Suggest you research the topic of "skew" and how this relates to trading. What you want is a system that delivers positive skew. Positive skew means that your average winners are greater than your average losers. This will deliver the better equity return in the long run. Your system has a very negative skew, which over time will lead to ruin.
Yes! Exactly. You hit the nail on the head there. I can have 300 wins in a row, wiped out by one losing trade. I know I need to work on this, didn't know the trading term for it.

Knowing that it's referred to as "Skew" will help me as I research ways to optimize for it. Thanks for the insight!

kasinath Jul 2, 2020 3:00am | Post# 10

{quote} Hi Kasinath, After many days and weeks of working, I found that it is better to work with a good indicator instead of timing the orders. The best for me is Chaikin Money Flow. It will filter your sideways and spreads. For pending orders, I prefer Limit orders because I go with the pullback.
I keep hearing about the Chaikin Money Flow, and it's on my to-do list to explore, because I do not have any Volume indicators in the tester.

I also hearp say that Volume precedes price movement, so I think I need one in my arsenal.

Thanks for the corroboration.

joyny Jul 2, 2020 5:22pm | Post# 11

2 Attachment(s)
See here how to propper optimize/backtest/forwardtest: https://blog.darwinex.com/dos-donts-...4-backtesting/

I prefer to optimize 2010 - 2017, then run forward test with 2017 - 2020.

Use MT5 for optimizations/testing because it automates forward testing.

Click to Enlarge

Name: mt5_Testing.png
Size: 26 KB

Choose the most stable parameters set. For example, you optimize 2010 - 2017 and see super-duper candidate with less dd and most profit - but you will notice that on 2017 - 2020 it can run with bad performance for example here:

Click to Enlarge

Name: mt5_Testing_forward.png
Size: 51 KB

Therefore use forwardtest (2017 - 2020) and choose the most stable parameters set which worked fine all period from 2010 - 2020.

This approach will help you avoid over-optimization issues... and you will see how your EA works with an unknown future - so no more need to run on demo account before going with real money.

kasinath Jul 2, 2020 5:59pm | Post# 12

See here how to propper optimize/backtest/forwardtest: https://blog.darwinex.com/dos-donts-...4-backtesting/ I prefer to optimize 2010 - 2017, then run forward test with 2017 - 2020. Use MT5 for optimizations/testing because it automates forward testing. {image} Choose the most stable parameters set. For example, you optimize 2010 - 2017 and see super-duper candidate with less dd and most profit - but you will notice that on 2017 - 2020 it can run with bad performance for example here: {image} Therefore use forwardtest (2017 -...
Thanks for your reply!
Unfortunately the link doesn't work and I cannot dig it up from the waybackmachine :-(

I am in the process of doing a full migration to mql5 so I can run better optimizations on MT5. Will take me some time.

I find it interesting that we can "forward" test on *historical* data. I had no idea MT5 offered this, nor do I know what it means, to be honest. IE: I though the whole point of a forward test was testing on future data. Hmm. I am going to learn more about it this weekend.

kasinath Jul 3, 2020 3:30am | Post# 13

See here how to propper optimize/backtest/forwardtest: https://blog.darwinex.com/dos-donts-...4-backtesting/ I prefer to optimize 2010 - 2017, then run forward test with 2017 - 2020. Use MT5 for optimizations/testing because it automates forward testing. {image} Choose the most stable parameters set. For example, you optimize 2010 - 2017 and see super-duper candidate with less dd and most profit - but you will notice that on 2017 - 2020 it can run with bad performance for example here: {image} Therefore use forwardtest (2017 -...
After some googling, I was able to find a video by Darwinex on YouTube with the same title as the URL you shared. It is fantastic. I learned more about backtesting strategies in one video than I did in 3 months of doing it.

Thanks again.

For everyone else, here is the video:
Inserted Video

squarty Jul 5, 2020 2:01pm | Post# 14

i follow your method it could be interesting

tadekcorona Jul 6, 2020 4:36pm | Post# 15

Hello Kasinath
I would love to test your EA
but I'm fine
nothing in the strategy tester
and on the DEMO account
I had one transaction on EUR / USD
with your settings
nothing.
Maybe I'm making a mistake
Please help

kasinath Jul 6, 2020 5:35pm | Post# 16

Hello Kasinath I would love to test your EA but I'm fine nothing in the strategy tester and on the DEMO account I had one transaction on EUR / USD with your settings nothing. Maybe I'm making a mistake Please help
Hi Tadekcorona,

If you mean you are not seeing any transactions in the strategy tester, this could be one of many reasons. I might be able to help if you PM a screen shot of your settings (input settings & time period settings) and the journal tab output.

Keep in mind: after much research and learning from this forum, I have decided that this EA is highly inefficient needs a lot more work. I am going to spend the next few weeks working on improving it, so you may want to wait before you continue testing it.

tadekcorona Jul 6, 2020 6:03pm | Post# 17

2 Attachment(s)
{quote} Hi Tadekcorona, If you mean you are not seeing any transactions in the strategy tester, this could be one of many reasons. I might be able to help if you PM a screen shot of your settings (input settings & time period settings) and the journal tab output. Keep in mind: after much research and learning from this forum, I have decided that this EA is highly inefficient needs a lot more work. I am going to spend the next few weeks working on improving it, so you may want to wait before you continue testing it.
Hello
Thank you for answering me
I'm sending this scr
Click to Enlarge

Name: 2020-07-06 15_00_05-the-trend-rider-tester.png
Size: 51 KB
Click to Enlarge

Name: 2020-07-06 14_58_39-312656_ FXChoice-Pro Demo - Rachunek demo - [EURUSD,H4 (visual)].png
Size: 42 KB

kasinath Jul 6, 2020 10:05pm | Post# 18

Ah, yes. I know this issue. "Trend Strength Filter" must be explicitly set to something. It should at least be set to 'None'.
For some reason, it didn't save that setting in the set file.

If you are looking to get the same profit curve I shared, use these settings:

  1. Trend Strength Filter = RSI
  2. Take Profit / Lock Profit =100
  3. Stop Loss = 3400
  4. Trailing Stop = 50
  5. RSI Period = 14
  6. # Of past Bars to Check RSI = 1


Please post your backtest graph if you run it successfully!

WARNING: These parameters will print a nice profit chart, but this does not mean it is a good EA. These parameters are are evidence of overfitting, and the stoploss / take profit ratio is *horrible*.

With that said, enjoy.


tadekcorona Jul 6, 2020 11:43pm | Post# 19

1 Attachment(s)
I think I'm unlucky
maybe he'll try again tomorrow
Thanks anyway for your help

Nothing went
Click to Enlarge

Name: 2020-07-06 20_39_20-312656_ FXChoice-Pro Demo - Rachunek demo - [EURUSD,H4 (visual)].png
Size: 51 KB

yellowhat89 Jul 7, 2020 12:03am | Post# 20

so I can not use this EA on live account?


© Forex Factory