#### Topic: Automated Trading Theory Discussion

I'd like a dedicated thread to discussion about automated trading theory. Automated trading is going to have a different approach to some extent than manual trading.

What do you fellas particularly look for when developing a strategy?

How do you evaluate a strategy? By profit, win/loss ratio, or something else?

Have you come across some legit resources on automated trading on the internet that you can share with the rest of us?

Please post your own (related!) questions and share your thoughts.

Cheers,
Zachariah

#### Re: Automated Trading Theory Discussion

Hi!

I'm trying to get a strategy which has a high trading frequency first. Only a lot of trades can show if a strategy is stable (at least 200 trades). Sometimes I use even 1-min-timeframe for this reason - but with 50.000 bars of 1-minute-data in FSB you get only 50.000 / 60 / 24 = 34,7 days of data. So I splitted my data to different directories (one dir for each month) and check the strategy for this data too. This is another "out of sample" test which shows if the strategy works. With 5-minute-timeframe it's much easier because you get there a couple of months of backtest data.

I'm checking profitfactor, profit per day and sharpe ratio. Besides that I care especially about the drawdown. It should be 15-20 percent maximum - of course the lower the better and I check the absolute values for the drawdown! Than I export the results and mix them (in excel) with the results of other (already running) strategies to see if the new system can help to make the equity smoother and steeper.

If everything is okay I test the strategy on a demo account. If some trades were executed I compare the executed trades with them in FSB (for this reason I have a directory with the current data) - the need to be opened/closed at the same price AND the same time!

Then I compare the results of backtest with them of the demo account. I compare the distribution of profits/losses - they need to show a similar picture (for this reason I split the profits/losses into classes and check if there are the same number of profits/losses in each class).

Hope this helps you to improve development of trading systems!

Bye,
erio

#### Re: Automated Trading Theory Discussion

Hey erio, thanks for the participation!

See this thread on how to bump up the 50k bar limit, though you did have a creative workaround.

I also use the Shape Ratio as a way of evaluating my strategies. Recently I've been working on the 5min time frame.

I have to take issue with the amount of down draw you allow. From my Forex education, I'm convinced that that is way to high. I allow 2 percent, and if I ever have success I will attribute it to this variable--such is how highly I regard this piece in a strategy. When trading, one needs to assure a large enough pool of trades that the strategies expected edge will play off. And 15% is way to dangerous. The around of winning that would need to be done to make up for a couple losses is crippling.

Currently I generate a batch of strategies over night (or other extensive period of time), then I go through them and weed out the bad ones, and save the decent ones. Then I go through my saved pile of decent ones and pick out the cream of the crop strategies, and demo those. I only have 2/3 of those.

I was really impressed with these cream of the crop strats, but recently when I bumped up my bars from 50k, to 65k (the furthest back my broker provides), they fell a bit and are less glorious, though still profitable. That realization was a bit sobering. They both had Sharpe's  above .50, one almost .70.
Now they are down to 30's and 40s.

My goal is to get a strategies that annualize 10% a year, and then have a few of them (as many as legit ones I can get) for diversification.

I also look at the smoothness of the equity chart for strategy evaluation. No one want something that's bouncing all over the place.

But as it stands, I haven't made a real cent, and am still demoing.

Cheers.

#### Re: Automated Trading Theory Discussion

Hi therealdrag0,

Maybe you misunderstood me: 15% of DrawDown isn't allowed for ONE trade but for the equity. On EUR/USD I've a stoploss of about 50-80 pips and trade only one lot on a 10.000 euro account. So a single trade can't loose 15%. Of course one can have bad luck and loose for example 7 trades (ore even more) in a row. I checked in several years hundreds of different trading systems and I learned that I can't get high profits without high risk. I'm ready to loose 1.500 - 2.000 euro during the year if the account shows 13.000 at the end of the year. Of course I have only a chance to get this if the system has a high trading frequency so that it takes not so much time to make profits again after a drawdown.

Bye,
erio

#### Re: Automated Trading Theory Discussion

Ah thanks for the clarification erio.

By my calculation 75 pip SL at 10k account trading 1 lot EUR/USD = ~8% risk. This is better but still too much risk for me. If I remember correctly, in the book Market Wizards the highest number any of the traders said they allow for risk is 6% and that was for a total of all open positions, for all systems and diversification on an account.

#### Re: Automated Trading Theory Discussion

Hi!

You are right. 80 pips is the upper limit for my stoploss - other systems only have 50 pips.

BTW: I discovered that some of my systems perform extraordinarily good if they open for example 0,1 lots first and if they get an additional signal in same direction and the first position is in profit they add 1,0 lots. Of course sometimes this makes greater drawdowns but overall performance is really amazing. Of course it is essential to limit the total number of lots which are invested by this way. Give it a try!

Bye,
erio

#### Re: Automated Trading Theory Discussion

@BTW. Interesting technique. Thanks for sharing! That's what this thread is all about. I'll check it out later

#### Re: Automated Trading Theory Discussion

Any techniques to indicate when a strategy stops working? The technique I have is N consecutive losers that is less than 5% probability, based on the strategy's win rate. This usually means around 3 - 5 in a row, and usually it is not a great technique. Sometimes it will get 4 losers one week, but then next week get all winners; or sometimes they go 2 losers-1 winner for a few weeks, just barely breaking even.

#### Re: Automated Trading Theory Discussion

@krog,
"When do you know a strategy is no longer working?"

This is something that I have wondered about myself, but I don't really have any answers. Mostly I am putting this off until I have one that I am live trading. But it is definitely an important aspect of trading to plan!

#### Re: Automated Trading Theory Discussion

Hi!

To find out if a strategy fails I do the following:

I enter each closed trade into an excel file. There I calculate a linear trend for the resulting account balance and around this 2 standard deviations up and down from this linear trend (like in bollinger bands). If the balance goes below the lower band it's a signal for me to be careful and maybe to stop the strategy.

Even better it is NOT to stop the strategy completely - reduce lotsize and let it go. So you still can enter the trades to your excel file and see if balance goes again up (of course you need to recalculate the profits so they match to the usual lot sizes). If it goes up: increase the lotsize again - if not you won't loose much.

Bye,
erio

#### Re: Automated Trading Theory Discussion

I like to look for a good Sharpe Ratio, ratio of winners to losers, and then profits.

My 'secret' goal is to push EA Studio until I can net 3000 pips per day....

#### Re: Automated Trading Theory Discussion

What is Walk Forward Analysis?

"Walk forward anaylsis is the process of optimizing a trading system using a limited set of parameters, and then testing the best optimized parameter set on out-of-sample data. This is similar to how you would use your expert advisor in live trading. The principles of walk forward analysis were first described in the book The Evaluation and Optimization of Trading Strategies by Robert Pardo.

To perform a walk forward analysis in MetaTrader, first optimize the expert advisor in the Strategy Tester. Then, choose the most profitable result in the Optimization Results tab, and perform a backtest it over a time period immediately following the optimization period. The end date of the optimization period is the same as the start date of the testing period. This process is repeated over and over until a satisfactory sample size is achieved.

If the expert advisor performs well in testing, relative to the optimization results, then one can conclude that the expert advisor will likely be profitable in live trading. If, on the other hand, the expert advisor performs poorly in testing, then either the optimization parameters or the length of the testing and optimization periods will need to be adjusted. If, after many attempts, the expert advisor still does not perform well in the testing, then it can be concluded that the trading system is unprofitable.

The animation to the right illustrates the walk forward analysis procedure. An optimization is performed over a longer period (the in-sample data), and then the optimized parameter set is tested over a subsequent shorter period (the out-of-sample data). The optimization and testing periods are shifted forward, and the process is repeated until a suitable sample size is acheived. [Source]
An Example of a Walk Forward Analysis

Let's provide a real-life example: We're going to do a walk forward analysis on an expert advisor, using EURUSD M30. We'll optimize this expert advisor over a period of 120 days. We've chosen the 3 or 4 most important parameters to optimize, so as not to over-optimize or "curve fit" the results. Also, fewer parameters means a quicker test.

We'll select the most profitable result, and backtest those parameters over a 30 day period immediately following the optimization period. It is recommended to use a testing period of approximately 25% of the length of the optimization period. Once we've recorded our results, we'll move the next optimization and testing period forward by 30 days.

After 12 consecutive rounds of optimization and testing, we'll have a year's worth of walk forward analysis data. We compare the average daily profit for the optimization periods to the average daily profit for the testing periods. This will give us a calculation called the walk forward efficiency ratio.

A walk forward efficiency ratio greater than 0.5 is considered a very good result. This is what we call a robust trading system. However, an expert advisor is tradeable as long as it is consistently profitable over multiple testing periods. If the walk forward efficiency ratio is negative, then that means that the expert advisor did not perform well relative to it's optimization results.

Of course, you can do a walk forward analysis manually in MetaTrader's Strategy Tester. But the process is tedious, time-consuming and prone to error. This is where the Walk Forward Analyzer software comes in. The program will automatically perform a walk forward analysis using MetaTrader's Strategy Tester over any length of time, with only a few settings provided by the user."

#### Re: Automated Trading Theory Discussion

We ca easily add Walk Forward Analysis to FSB, but I do not see any benefits from it.

#### Re: Automated Trading Theory Discussion

I think the benefit, will be that it will eliminate curve-fitting.
Besides, if this is so easy, then why not?

But, maybe better for it would be possibility to test generated strategy, against few different currency cross at once?

#### Re: Automated Trading Theory Discussion

Next major release will have multiperiod and multicurrency indicators.

I'll possibly add Walk Forward Analysis. Can you collect and provide more info (articles, formulas, books) on that topic.

(FSB V3.0 with these features can be expected on December.)

#### Re: Automated Trading Theory Discussion

Walk-forward test can be done now too in FSB, it's only more manual approach setting up the right data horizons at each optimization loops. One has to keep notes on results too, of course.

Popov wrote:

Next major release will have multiperiod and multicurrency indicators.

Wow, that's a bombshell. How big of a change it will be in terms of indicator coding and the way they are built up today?

#### Re: Automated Trading Theory Discussion

Wow, that's a bombshell. How big of a change it will be in terms of indicator coding and the way they are built up today?

No big change probably. I think to add additional menus for Symbol and Period in Indicator Parameters Window. They will be set to main data by default. Actually for that option no change to indicators will be required.

I made some tests with separating data from calculations. The only change to indicators was a single line.

``````// New constructor
public Accelerator_Oscillator(IDataSet dataSet, SlotTypes slotType)
: base(dataSet)
{
...

// Old Constructor
public Accelerator_Oscillator(SlotTypes slotType)
{
...``````

As you see FSB injects a data set to indicator via its constructor.
I have a working alpha version, but it doesn't provide multisymbol / period strategies yet. You can compile it from exp branch of GitHub. It allows several Generators or Optimizers running from a single copy of FSB. But this is only experiment. If you want I can publish a testing exe.

The real problems will be making FST trading such strategies. Expert must provide and update all required data files to FST.

#### Re: Automated Trading Theory Discussion

acerguest wrote:

I think the benefit, will be that it will eliminate curve-fitting.
Besides, if this is so easy, then why not?

I am not sure it will eliminate curve fitting.  At the moment there is the option to select to filter OOS performance in the generator. This only allows strategies with good OOS performance to be saved. Anything else is discarded. But the very fact that you have selected this option makes the OOS data in sample. It "contaminates" your test strategy with walk forward data. I suppose you could always have another set of OOS data which it would check against after testing the first set of OOS data. That should give better confidence but the same "contamination" issue is there. This has been discussed on previous threads and I am not sure we came up with an answer.

#### Re: Automated Trading Theory Discussion

I think SpiderMan is right. If a strategy passes Walk Forward Analysis, it for sure will look well on full data test and vice versa, a good balance curve on full data will be good also on Walk Forward test. So what is the difference?

#### Re: Automated Trading Theory Discussion

Popov wrote:

No big change probably. I think to add additional menus for Symbol and Period in Indicator Parameters Window. They will be set to main data by default. Actually for that option no change to indicators will be required.

I made some tests with separating data from calculations. The only change to indicators was a single line.

As you see FSB injects a data set to indicator via its constructor.

I have a question about the new multicurrency feature - is there only 1 dataset per indicator available or will it be possible for the indicator to use more than 1 dataset? For example, calculate moving averages of 2 pairs in one indicator, and then use those values in the following calculation.

#### Re: Automated Trading Theory Discussion

It sounds possible. At least I do not see a reason for the opposite.

#### Re: Automated Trading Theory Discussion

I like walk forward and I use often the tool described in the thread....

FSB has its own facility for the same and is a lot faster.

I feel that a trader can fool himself with both tools if he wants to, this is a decision that each must make for himself.

My 'secret' goal is to push EA Studio until I can net 3000 pips per day....

#### Re: Automated Trading Theory Discussion

I also use this Walk Forward Analysis program and I believe it is important for a winning strategy. It's good to be done periodically as well.

Will be great to have this function in the FSB.