Forex Factory (https://www.forexfactory.com/forum.php)
-   Trading Systems (https://www.forexfactory.com/forumdisplay.php?f=71)
-   -   Old Dog with New Tricks (https://www.forexfactory.com/showthread.php?t=211657)

Ronald Raygun Dec 15, 2009 5:00pm | Post# 1

Old Dog with New Tricks
 
2 Attachment(s)
It's been awhile since I've seen any new and interesting trading systems on this forum, so I guess it's my turn to contribute.

I realize that my recent postings have been far an few between. Trust me, there has been good reason.

For the past two years, my trading has been very much EA-based. The problem of course was I found myself constantly optimizing and updating my EAs. It's a fairly tedious process and requires a good amount of analysis on my part. All of the EAs were also problematic in the sense that they are 'dumb'. They do not really analyze the market and try to determine if the current trading market is good for them. That's something I've had to do manually.

Now, I new I needed to come up with some sort of self-optimizing EA, or at least an EA smart enough to know whether or not a specific trading strategy is good for a particular market. There were attempts made to try and mechanically determine if a market was trending or ranging, but that didn't work out too well. There was an article on the MQL codebase explaining how to get an EA to optimize itself, but it was tricky to implement and wholly unreliable.

This system is one of my more promising attempts, and can be very heavy on computer resources. It uses the bars on the chart to try and run a very crude backtest. Based off of the information in that backtest the EA can then decide whether or not the market is appropriate for them. The initial system is based off of an old one: New Highs and New Lows.

At its core, if there is a new high, the EA will place a long trade--assuming it expects a breakout--or a short trade--assuming it expects a counter trade. Consequently, if there is a new low, the EA will place a short trade--assuming a breakout--or a long trade--assuming a counter trade.

The system itself is very simple, there is no doubt about that. The underlying analytics took awhile to code and attempt to perfect.

Every day when the day starts, the EA will re-run the crude backtest to determine if the market is still suitable for a particular trading system.

 

  1. extern string Remark1 = "== Main Settings ==";
  2. extern int MagicNumber = 0;

    1. This number should be unique when multiple EAs are attached to a terminal.

  3. extern bool SignalsOnly = False;

    1. If set to true, the EA will only alert you to a trade using any combination of the alerts below.

  4. extern bool Alerts = False;

    1. If set to true, the EA will send a pop-up alert when a trading signal arrives.

  5. extern bool SignalMail = False;

    1. If set to true, the EA will send you an e-mail (assuming you set up your mail in your MT4 Terminal.) when a trading signal arrives.

  6. extern bool PlaySounds = False;

    1. If set to true, the EA will play the file, "alerts.wav" when a trading signal arrives.

  7. extern bool ECNBroker = False;

    1. Some brokers require EAs to first place a trade, and then modify the trade with the stoploss and takeprofit. If your broker requires this, set this value to True.

  8. extern bool CloseOnOppositeSignal = True;

    1. If set to true, the EA will close a trade if an opposite trading signal appears.

  9. extern bool EachTickMode = True;

    1. If set to true, the EA will take a trade immediately if it sees a signal. If set to false, the EA will take a trade only if there is a signal at the end of the bar.

  10. extern double Lots = 0;

    1. Fixed lot size

  11. extern bool MoneyManagement = False;

    1. Enables/Disables the lot sizing function.

  12. extern int Risk = 0;

    1. The percent of your available margin that you are willing to put into a trade.

  13. extern int Slippage = 5;

    1. Maximum slippage allowed when placing an order.

  14. extern int StopLoss = 100;

    1. Hard Stoploss in pips.

  15. extern int TakeProfit = 60;

    1. Hard take profit in pips.

  16. extern string Remark2 = "";
  17. extern string Remark3 = "== HiLo Settings ==";
  18. extern int BarStart = 0;

    1. This is the number of bars in the chart history that the EA will check when running its backtest. Set to 0 to use all bars on the chart.

  19. extern int InitialRange = 10;

    1. The EA looks for new daily highs and lows. This is the number of bars after a new day starts to establish those highs and lows.

  20. extern double WinPercent = 0;

    1. This is the minimum win percentage required before an EA decides on which system to use.

  21. extern double MinimumSuccessScore = 0;

    1. This is the minimum success score required before an EA decides which system to used.

  22. extern int MinimumConfidence = 90;

    1. This is the minimum confidence allowed. Confidence is the number of trades which could not be assign a win or loss.

When you attach this EA to the chart, you'll see the following parameters:

Breakout Win: Number of breakout trades in backtesting that won.
Breakout Loss: Number of breakout trades in backtesting that lost.
Breakout Unsure: Number of breakout trades in backtesting where the EA isn't sure if the trade won or lost.
Counter Win: Number of counter trades in backtesting that won.
Counter Loss: Number of counter trades in backtesting that lost.
Counter Unsure: Number of counter trades in backtesting where the EA isn't sure if the trade won or lost.
Breakout Percent: Percent of trades that won.
Breakout Success Score: The success score of the breakout style trading. (See how I rate systems to understand how I calculate success score.)
Counter Percent: Percent of trades that won.
Counter Success Score: The success score of the counter-trend style trading.
Tester Quality: The percent of trades where the EA is certain of the outcome (win/loss)
High Value: The current daily high price.
Low Value: The current daily low price.
Trading Style: the trading style that the EA uses.


[EDIT]

The previous version of the EA didn't have the CloseOnOppositeSignal value enabled. These versions do.

HiLo Trader [TD] Lines paints lines showing where the internal backtesting engine would have placed high and low trades.

I should probably also explain how the backtester works.

The EA can see every bar that is on the chart. Based on how many bars it is told to look back, the EA checks for highs and lows. When a new daily high is made, the EA calculates what the TP and SL are, and then checks the next few bars to see if the TP or SL is between the high and low of that bar (including the entry bar).

 

  1. If either the TP or SL is hit in the entry bar, the EA adds to the 'Unsure' count..
  2. If the TP and SL is hit in the same bar after the entry bar, the EA adds to the 'unsure' count.
  3. If the TP is hit in a bar after the entry bar, and the SL was never touched, the EA adds to the 'win' count
  4. If the SL is hit in a bar after the entry bar, and the TP was never touched, the EA adds to the 'lose' count.

HiLo Trader [TD] Lines.ex4
HiLo Trader [TD].ex4


dkhinckley Dec 15, 2009 8:19pm | Post# 2

RR, given your reputation, I find it amazing that it's been over 3 hours since you posted and no one else has replied yet! I'm sure they'll catch up.
Thanks for the EA. I'll definitely check it out.
Dave

jimsforex Dec 15, 2009 9:52pm | Post# 3

Details
 
RR,

This is conceptually interesting.
The devil is always in the details.

We anticipate the details with bated breath.

Jim
a

Ronald Raygun Dec 15, 2009 10:29pm | Post# 4

RR, given your reputation, I find it amazing that it's been over 3 hours since you posted and no one else has replied yet! I'm sure they'll catch up.
Thanks for the EA. I'll definitely check it out.
Dave

Been watching the downloads, people are definitely playing with it. I see the ticks being loaded into the database. I guess it's working for them. I know it works for me. =D

mhall Dec 15, 2009 11:21pm | Post# 5

Thanks RR. I will give it a try. Does it matter what time frame? I am assuming the chart should be on daily. Is that correct?

Thanks again.

Ronald Raygun Dec 16, 2009 12:20am | Post# 6

Timeframe does matter. Remember, the pseudo backtest uses the bar history. Basically, the EA scrolls back on the chart.

BenScoobert Dec 16, 2009 5:51am | Post# 7

Great idea in theory Ron, I hope it works in practice, I've set up a client with it on to see how it goes.
I have a question

extern bool TickDatabase = True;

  1. If set to True, the EA will send tick data into the tick database.

this option is not there, is this now compulsary as dll import needs to be enabled?


Ronald Raygun Dec 16, 2009 8:50am | Post# 8

This EA is my first attempt at having bidirectional communication between a webserver and a client.

In theory it can generate all the statistics by itself. But bar data isn't nearly as reliable as tick data, and that's where this connection comes in. The server can feed the EA statistics based on the broker and the quality of data.

And yes, I am forcing users who use this EA to contribute ticks into the database. In exchange for their streams, the EA is receiving its own mini stream of information. Frankly, I like to think it's fair. Besides, the increased redundancy in tick streams ensures that I have a solid gap-free data set for this EA and my own research to run off of.

SkyzerFX Dec 16, 2009 9:07am | Post# 9

It's possible to show just an Example chart with some

points sell/ buy /SL how and what exactly the Robot doing?

Thank you.

Jiee Dec 16, 2009 9:28am | Post# 10

A self optimizing EA would free up a lot of time wasted on monitoring the markets, if it works then this would be a fairly substantial achievement in my opinion. I'll give it a whirl after my exams are over.

I haven't used this "tick database" before but I can probably imagine its just a collection of tick data uploaded from various users across various broker feeds, so making a forced upload seems like a good idea. That way like you said anyone who uses it is then at least forced to contribute something to the process.

The ingenuity of some of the traders/coders on this forum never ceases to amaze me.

--- Joe

Ronald Raygun Dec 16, 2009 9:54am | Post# 11

1 Attachment(s)
Here is an example of an EA standing aside.

You'll notice that there are two lines shown, these are the current day's high and low as determined by the EA. the EA shows yellow lines when it is standing aside.
Click to Enlarge

Name: hilo example.gif
Size: 13 KB

Ronald Raygun Dec 16, 2009 9:55am | Post# 12

2 Attachment(s)
Here is an EA priming for and eventually taking a short order.
Click to Enlarge

Name: hilo example counter.gif
Size: 13 KB
Click to Enlarge

Name: hilo example counter short.gif
Size: 13 KB

Ronald Raygun Dec 16, 2009 9:55am | Post# 13

1 Attachment(s)
In the ~5 minutes I took to make this series of posts.

I just made 10 pips.
Click to Enlarge

Name: hilo example counter short exit.gif
Size: 12 KB

Dr.Geppynius Dec 16, 2009 10:09am | Post# 14

It's been awhile since I've seen any new and interesting trading systems on this forum

it's because you have not yet visited our vsa thread

reachjj Dec 16, 2009 10:10am | Post# 15

1 Attachment(s)
Hi,

I tried putting this on USDCHF M1 TF. I can see from the chart that, there were more losses than profits. Can you tell me, if there is anything wrong with that.

And looks like, counter trend trading has given more profit than breakout. Can you give an option in EA to chose either one/both something like that.


Thanks,
Prakash
Click to Enlarge

Name: 15.gif
Size: 24 KB

Ronald Raygun Dec 16, 2009 10:13am | Post# 16

Hi,

I tried putting this on USDCHF M1 TF. I can see from the chart that, there were more losses than profits. Can you tell me, if there is anything wrong with that.

And looks like, counter trend trading has given more profit than breakout. Can you give an option in EA to chose either one/both something like that.


Thanks,
Prakash
Nothing wrong with that.

That's the whole point behind this EA. It's designed to pick for you.

reachjj Dec 16, 2009 10:17am | Post# 17

Nothing wrong with that.

That's the whole point behind this EA. It's designed to pick for you.

So based on this past data, it tried to take either counter trend or breakout trading... is that what you mean.

Thanks for this system.

hope we make some nice pips out of it.

Thanks,
Prakash

Ronald Raygun Dec 16, 2009 10:28am | Post# 18

So based on this past data, it tried to take either counter trend or breakout trading... is that what you mean.

Thanks for this system.

hope we make some nice pips out of it.

Thanks,
Prakash
Yes. The EA analyzes the market for you

fxtrader08 Dec 16, 2009 11:32am | Post# 19

Hi Ronald,

Thanks for sharing your work. Much appreciated.

What period of time is this backtest going over?

Where we have number of wins, is it safe to say:

Number of wins x TP = Pips gained?
Number of losses x SL = Pips lost?

Or will this vary?

Warm Regards,

fxtrader08

Ronald Raygun Dec 16, 2009 11:38am | Post# 20

Hi Ronald,

Thanks for sharing your work. Much appreciated.

What period of time is this backtest going over?

Where we have number of wins, is it safe to say:

Number of wins x TP = Pips gained?
Number of losses x SL = Pips lost?

Or will this vary?

Warm Regards,

fxtrader08
Internal backtest goes for as many bars back as you tell it to.

The win/lose values are based off of the bar itself. There is no guarantee that the EA is 100% correct when it tells you the number of trades won/lost. You can multiply the trades won * number of pips but there really is no need to...


© Forex Factory