Read More…]]>“The trend is your friend”. This famous phrase is in almost all trading books. But how important is it to trade in the direction of the trend? This is the question I asked myself. Before answering this question, we will discuss some generalities. Whereof is usually composed a trading strategy:

An entry that gives us an advantage (edge) compared to a random input. The input can be decomposed into elements such as setup, filters, signal, execution, etc …

Exit with loss (stop loss) or profit (take profit).

Management of risk (money management) that allows us to maximize profit while minimizing risk.

We’ll start with the entry. According to several authors such as Van Tharp, author of the famous book “Trade Your Way to Financial Freedom”, the input is the least important component of a trading system. Think about it. Before taking a position, the trader is not at risk. He can think long and wide at his entry. Once this entry is executed, the trader is at the thank of the market and the quality of his exit will decide the profit he will take or at least, how he will minimize the loss. Is it not that the purpose of trading?

I agree that we need an entry that provides a minimum benefit. For this reason that we need a tool to assess the quality of input. This tool will be the MER (Maximum Excursion Ratio). Others call it the e-Ratio. It consists of evaluating the relationship between the advantage offered a position in the market versus the risk to which it exposes you. In more technical terms:

MER = MFE/MAE.

MER : Maximum Excursion Ratio

MFE : Maximum Favorable Excursion which corresponds to the maximum potential benefit that the position offered. It is calculated as the difference between the extreme favorable reached by the market and the price of entry.

MAE : Maximum Adverse Excursion which corresponds to the maximum potential loss that the position was offered. It is calculated as the difference between the negative extremum reached by the market and the price of entry.

Some normalize the ratio by a factor of volatility (eg ATR) to compare different markets.

The concept of MFE and MAE was introduced by John Sweeney author of “Maximum Adverse Excursion: Analyzing Price Fluctuations for Trading Management.” The beauty of this concept and that ratio is obtained (MER) will also be good to assess entries and exits.

The post is becoming long and you wonder: What is the relationship with “The trend is your friend”. Patience. I get there …

I’ll start by evaluating a popular entry (the price crosses its moving average) to see how it gives us an advantage in using the MER. I add a filter which consists in taking position only in the direction of the trend of higher time frame and compare MERs. If the filter improves our advantage, that means the trend was really our friend.

Buy when the last candle crosses, rising, moving average of period N. Close position after N bars.

Sale when the last candle crosses, downward, moving average of period N. Close position after N bars.

Test for the period N, between 24 and 100 with a step of 2.

For tests with filter: Buy only when the price is above the moving average D1 of the same period N. Sale only when the price is below the moving average D1 of the same period N.

The results

Figure 2 : MER for a period of the moving average from 24 to 100. EURUSD: 2008-2011

Figure 3 : Profit / loss for the period of the moving average ranging from 24 to 100. EURUSD: 2008-2011

H1 only

H1+D1

Random

MER

1.03

0.98

1

# trades

14115

12252

20926

$

7016±1744

37771±1944

-36333±2977

$ / trade

0.5

3.08

-1.74

MER in the table is the average MER in Figure 2 for each test. The number of trades and profit totals are not means. $ / trade is profit per trade in Metatrader called Expected Payoff.

Conclusion

The filter has not improved the MER, which was our measuring tool. This suggests to me that the MER, better reflects the quality of the input, which in this case does not offer any particular advantage over a random input. However, the filter significantly improved profit and profit per trade. On 14,115 trades (without filter), the filter was cut 1863 trades responsible for loss of 16.5 $ per trade ((37771-7016) / (14115-12252) = 16.5). That means he has cut overall worst trades.

So the trend is probably our friend, but it certainly is not our enemy.

Read More…]]>Can a strategy based on a random input with a suitable output and money management be profitable? Dr Van Tharp in his book Super Trader, said he did the test in 10 markets over a period of 10 years, and says the results were positive in a consistent manner.

“It didn’t make a lot of money and you had to live through some nasty drawdowns, but over the 10 years it made money.” Super Trader p.149.

Is it possible to reproduce such results in Forex. This is the subject of today’s article. The test protocol will be as follows:

Because of the random nature of the input, the results will be different from one test to another, for the same currency pair and the same period. For this reason, and for the test to be meaningful, I did 10 tests for each currency pair and calculate the mean and standard deviation at the end of the table.

1- Test without money management

EURUSD

GBPUSD

USDCHF

USDJPY

USDCAD

AUDUSD

NZDUSD

$

-1960

-8506

-569

-2795

-5749

-8320

1979

$

519

-2791

2089

-1002

-3449

4027

-4470

$

4195

-5512

3155

-1293

-3232

1117

895

$

-1027

-3970

-613

-1520

-148

-5249

-2963

$

2728

-1380

1962

-78

560

1349

164

$

-3158

-1388

-2237

821

-586

-9438

-3672

$

-1093

3936

322

1194

591

-1959

-5382

$

-1214

-5877

-438

-1731

-381

-4870

-3745

$

-1246

2631

-354

-4504

-471

-4179

-1053

$

1798

-4584

4190

2220

1216

-2836

-2249

Moyenne

-46

-2744

751

-869

-1165

-3036

-2050

-1308

Ecart-type

2300

3841

2006

1988

2229

4295

2453

2730

2- Test with money management (1% of capital)

EURUSD

GBPUSD

USDCHF

USDJPY

USDCAD

AUDUSD

NZDUSD

$

-518

148

439

268

-258

196

168

$

-195

51

1215

181

831

-269

-595

$

471

0

-433

-919

-581

-1232

91

$

973

-1227

120

-374

-1237

463

-881

$

-67

85

476

300

955

-1243

-1937

$

749

1028

-666

26

-519

-2067

-1182

$

-136

-963

259

778

-1246

-571

-684

$

1021

-896

-868

831

395

-2858

-448

$

-140

520

-845

477

103

647

-1584

$

855

-693

889

569

292

-964

-504

Moyenne

301

-195

59

214

-127

-790

-756

-185

Ecart-type

572

722

733

534

778

1119

670

733

Conclusion

It is clear that the result is negative. Therefore, such a strategy can not be used to trade Forex. Money management has greatly improved the result (-185 ± 733 instead of -1308 ± 2730), as well as the average standard deviation, but not to the point that the strategy becomes usable. However, the use of trailing stop may be interesting to compare and evaluate the different inputs that give advantage compared to a random input. This makes another tool we will use in future articles.

Read More…]]>If there is a popular technique in trading, it is the moving averages (MA) crossover. We saw in a previous article that the problem of the strategy based on the MA was whipsaw. We then presented a technique that corrects the issue in the article on the Keltner bands. The technique of using crossing of two MA goes in the same direction. In fact, see the slow MA (the one with the largest period) as a trend indicator and the fast MA as a filter that shows the price movement without noise (random and sudden movements which immediately affect the main movement of the price). So, by waiting the fast MA to cross the slow one, we avoids the disadvantages of whipsaw.

As usual, the strategy I will test today will be based on the basic technique, the Stop-and-Reverse one. The rules are simple and can be summarized as follows:

Buy: When the fast MA crosses the slow MA from bottom to top, buy at the opening of the next bar.

Sale: When the fast MA crosses the slow MA from top to bottom, sell at the opening of the next bar.

All tests are performed with an initial capital of $ 10,000 on EURUSD for the period from 01-01-2008 to 01-01-2012 and for different time intervals (M15, H1, H4 and D1). Volume of trade = 1 mini lot ($ 10K). For each timeframe, I vary the period of fast MA from 1 to 9 with a step of 1 and the period of slow MA from 10 to 100 with a step of 5. Finaly, I will present the results of the optimization as topographic surface to see if there is a region where the results are stable.

Results of the optimization of periods of two moving averages

Table 1 shows a gradual improvement in the overall results towards the upper timeframe. I will draw the results of D1 (daily) topographic surface trying to find a stable region where you can choose the optimal parameters of MA periods for trading.

Figure 1: Topographic surface profit/loss according to the periods of two moving averages

Figure 1 shows generally positive results. Except some brown spots showing negative results, the rest of the surface shows positive results. The most interesting region is between 40 and 50 for the slow MA and between 2 and 4 for the rapid MA.

Conclusion

The strategy of MA crossover has passed the test of time and continues to show positive results. What is the most important when optimizing the parameters of a strategy is to be able to find an area where the results are positive and stable. This reassures us that even if the market changes a little bit, chances are good that we continue to make profits. This strategy gives us what we want in the region (40-50, 2-4). Although it displays very interesting results, this strategy has drawbacks: a large drawdown (up 30%), a high number of consecutive losses and a low percentage of winning trades which generally does not exceed 40%. This strategy is stressful and stress is the price to pay for a winning strategy. However, there are ways to reduce these drawbacks by diversification (trade several pairs) and combining it with another strategy that is not a trend following.

Read More…]]>The MACD is the famous indicator invented by Gerald Appel in the 70s. It measures the amplitude of divergence between two moving averages. This indicator is very popular, systematically found in all trading platforms. It can be used in different type of strategy: like momentum indicator for trend following, oscillator for range-trading, etc. … In this article we will see how someone could reinvent the MACD. The goal of the exercise is to learn together some techniques and mathematical manipulations that can eventually help you later to create your own indicators to highlight a particular observation or answer any needs.

I take this opportunity to pay tribute to this talented man who created the MACD Gerald Appel. It is always easier to reinvent the wheel when someone has already done. Mr. Appel, in addition to being an outstanding manager and trader, is the author of several books on trading, including:

By observing the graph of the EURUSD, you notice that the price moves in the form of waves. And in addition, this movement is around moving average waves which was displayed on your graph. You say to yourself, it would be interesting to isolate this movement back and forth around the moving average and the highlight on a graph separately. The first instinct that comes into your head and subtract the moving average price and the result is a line that oscillates around zero.

You’re already proud of your results, but you find that the line is not smooth enough to your taste. You think immediately to smooth using a moving average. So instead of displaying the difference between the price and its moving average, you decide to show the difference between two moving averages, a fast MA (period = 12) used to smooth prices and a slow MA (period = 26 ) which serves as a pivot around which oscillates the price. And this is how you get your first version of MACD.

You start already to think about how to develop a trading strategy based on your new creation. You say to yourself, I’ll hang position based on my MACD crossing with the zero line. When it crosses the bottom to the top, I buy and when it crosses the top down I sell. And suddenly, you smile because you realize that your strategy is none other than the famous strategy of crossing of two moving averages. But you want to innovate and the idea you just try to get in position earlier using something you’ve seen playing with the stochastic. It was to use another curve which crossing signals a change in momentum (hence its name: signal curve). This is simply a moving average of small period (period = 9) of your MACD.

Then, the ideas of strategies begin to rush through your head, and you decide to note to not forget them:

Strategy # 1: Buy when MACD crosses its signal from the bottom upwards and close the position when the MACD crosses zero. Sell ​​when the MACD crosses its signal from high to low and close position when the MACD crosses zero.

Strategy # 2: Buy when the MACD crosses its signal from the bottom to the top. Sell ​​when the MACD crosses its signal from high to low. Each position closes the previous one. (Stop & Reverse)

Option # 1 Strategy # 2: Buy when the MACD crosses its signal from the bottom to the top and MACD below zero. Sell ​​when the MACD crosses its signal from high to low and MACD greater than zero. Each position closes the previous one. (Stop & Reverse)

Option # 2 Strategy # 2: Buy when the MACD crosses its signal from the bottom to the top and MACD above zero; Close position when the MACD crosses its signal in the opposite direction and the MACD is still greater than zero. Buy when the MACD crosses its signal from the top down and MACD below zero; Close position when the MACD crosses its signal in the opposite direction and the MACD is still below zero. (Note: This is a simulated purchase of correction in the direction of the trend.)

…

And a new idea has emerged of your head. Your MACD is an oscillator unbounded. It would be good if you can turn it into a bounded oscillator (between 0 and 100) to be able to use it to identify areas of over-bought and over-sold in a range-trading strategy. And, once again, new ideas for strategies begin to shake in your head. Except this time, you are no longer able to resist the urge to sleep and you say: “I’ll finish it tomorrow, or … maybe next week.”

Read More…]]>The Donchian Channel was developed by Richard Donchian, who used a 50 weeks period in the original strategy. The idea is to buy when the price breaks the upper band of the channel (maximum 50 weeks) and sell when it breaks the lower band of the channel (minimum 50 weeks). However, this is Richard Dennis who popularized the technique in the 80s because it was the basis of the technique taught to a group of turtles. This famous group born out of a bet between Richard Dennis and his friend Bill Eckhard.

There are several strategies based on Donchian channel. They have a common entry point (the case of a channel band) but they differ in the output:

The case of the opposite band the channel, with the same period or shorter period.

Return to the median strip: The average of the upper and the lower.

Take-profit and Stop-Loss based on ATR

…

For today’s test, I chose the first option, the rules are as follows:

Buy: Buy when the price breaks and closes above the upper band (the maximum of the last 20 candles). Close position when price closes below the strip affixed.

Sale: Sell when the price breaks and closes below the lower band (the minimum of the last 20 candles). Close the position when the price closes above the band affixed.

For optimization, I will try out a different period than the input. To ensure that the output period is less, I used a factor (0.2 to 1) which multiplies the input period.

The tests are performed for the period from 01-01-2008 to 01-01-2012. The initial capital is $ 10,000. The volume of trade is 1 mini lot (10K).

- Results without optimization

EURUSD

USDJPY

I chose the USDJPY to show you an example of a currency pair for which the strategy is not working. The following table summarizes the results for other major currency pairs with the default settings (Period = 20).

Conclusions

This strategy based on the Donchian channel is very simple and gives good results on some currency pairs. This confirms the fact that the currency pairs do not behave the same way or each pair has its own personality. To try to take advantage of this phenomenon, I reversed the rules for USDJPY (buy when you need to sell and sell when you need to buy) is called fading. I almost fell off my chair seeing the graph with the default settings (Fig. 6). So the idea is to trade with the strategy pairs for which it works well and reverse rules for others. However, I advise you to use demo accounts every time you want to explore new ideas. Be careful because a currency pair can change personality! This is the art of trading!

Read More…]]>One weakness of the strategy of price crosses its moving average, is the many whipsaw, closing the position at a loss before the trend has a chance to settle. This is why trading slope of the moving average gives better results; It takes position when the trend is sufficiently established.

The whipsaw is a component of market volatility. One way to avoid them is to create a band of volatility around the mean. We have already discussed this approach in the article about Bollinger Bands. Indeed, trading the breaks of Bollinger Bands reduces sensitivity to market noise.

Note: I often give links to pages online because I find relevant content. This does not mean that I endorse the contents of other pages. So be careful!

My goal today is to test a trend strategy based on Keltner channel. The rules can be presented as follows:

Buy: when the price closes above the upper band, buy at the opening of the next bar. Close the position when the price closes below the moving average.

Sale: when the price closes below the lower band, sell at the opening of the next bar. Close the position when the price closes above the moving average.

All tests are done with an initial capital of $ 10,000, on EURUSD, for the period from 01-01-2008 to 01-01-2012 and for different time frames (M15, H1, H4 and D1). Volume of trade = 1 mini lot ($ 10K). For each time frame, I vary the period from 10 to 100 with a step of 2. I will present the results of optimization in the form of a curve to see if there is a region where the results are stable.

Optimization results of the period of the moving average

Figure 1 : Profit / loss according to the time frames for a period of the moving average and ATR ranging between 10 and 100 of a step of 2

Figure 1 show clearly that H1 and D1 are the time frames that provide the best results. The following table presents the average profit / loss (Average), standard deviation (Std) and the ratio of Average / Std. H1 definitely gives the best results.

Results with optimization of the period of the moving average and the ATR factor

H1 curve shows some stability above zero from the period 40. I wanted to see how this stability could be affected, for better or worse, if we vary the ATR multiplier. This factor was fixed at 2 in the previous test. In Figure 2, we clearly see a stable region around the point (74, 1.5).

Figure 2 : Topographic map of the profit for the period ranging from 10 to 100 and the ATR factor ranging from 1 to 5.

Conclusion

The strategy based on the Keltner channel keeps its promises. Positive results on a wide range of time frames (from H1 to D1), with the best at H1. Some stability for the period as well as for the ATR multiplier factor. The presence of a volatile component (ATR) in this strategy gives us some confidence to his ability to hold if the market volatility changes.

If you like this website, please recommend it to your friends. If you want it to be better, please leave us a feedback.

Read More…]]>The moving average is perhaps the most popular technical analysis tool of markets. According to this article, its use for smoothing data goes back to the early 20th century. Its use to define the market trend is everywhere, on traders screen as well as specialized media screens. It is impossible to find a book of technical analysis that does not speak about moving average and it seems that strategies based on the crossing of two moving averages are the few classics that continue to work.

“The variations on moving average indicators are so numerous that a book could be devoted exclusively to their various flavors.” Mechanical trading systems, p.18.

The goal of this article is to let you taste some flavors of this popular indicator. However, in order to be brief, I limit the discussion to the use of a single moving average. We will return later in other articles to the use of two or even three moving averages.

The tests are done on the EURUSD, with an initial capital of $ 10,000 for the period from 01-01-2008 until 01-01-2012 and the time frame of M15. Volume of trade = 1 mini lot ($ 10K). But before presenting the test results, I’d tell you a trick I use to make a sweep of a broad spectrum of time intervals without crashing my computer. During the optimization process, I use a single time frame M15, but instead of varying the period of a fixed step (linear scale), rather I use a logarithmic scale. So I vary what I call MaPeriodPower from 3 to 15 which corresponds to a period of 2 ^ 3 to 2 ^ 15 times M15. I hope this is clear, otherwise I will return to in the next article.

1 – The calculation method (simple, exponential, smoothed, balanced)

The goal is not to show you how to calculate the moving average, first of all, because you do not need to do so and second, because there are lots of websites that already do this, but to evaluate the best method for a trading strategy. Certain authors, each according to their employed strategy, see no advantage in using other one but Simple Moving Average. Others, prefer the exponential for its ability to respond to recent changes. Personally, I prefer to pass the test and “let the best guy win” …

The test protocol:

Stop and Reverse: Buy when the price crosses, from bottom to top, its moving average. Sell ​​when the price crosses, from top to bottom, its moving average.

Calculate the average value of profits and the standard deviation and the ratio (profit/standard deviation) will be used to compare four methods for calculating the moving average (higher the ratio will be, better the method of calculation for our strategy will be)

SMA

EMA

Smoothed

Weighted

Average

-2215

-1707

-1126

-2335

Std

5234

5246

4682

5660

Ratio

-0.423

-0.325

-0.241

-0.413

Figure 1 : Profit/Loss for the 4 methods

The winner of the first test is the smoothed moving average. For the following tests, I’ll take this type of calculation.

2- Calculation applied to … (Close, Thypical price, Weighted close)

Thypical price = (High + Low + Close)/3

Weighted close = (High + Low + Close x 2)/4

Close

Typical

Weighted

Average

-1126

-1118

-1125

Std

4682

4686

4693

Ratio

-0.241

-0.239

-0.240

The difference is in no way significant. It is useless to display the graph.

3- The price crosses moving average or the slope?

The two most popular strategies using a single moving average are:

The price crosses its moving average

The moving average slope changes

Price

slope

Average

-1126

-57

Std

4682

4442

Ratio

-0.241

-0.013

Figure 2 : Profit / Loss for both strategies (the price crosses and the slope of the moving average)

Conclusion

According to test results, the best combination to use for a strategy based on a single moving average is : a smooth type calculation applied to the closing price and to trade the average slope instead of the crossing of the price with its average.

If you like this website, please recommend it to your friends. If you want it to be better, please leave us a feedback.

Read More…]]>There are several strategies based on Bollinger Bands. I choose two of them for my first test.

Strategy # 1:

The classic strategy uses Bollinger bands as support and resistance. Indeed, we trade the bounce of bands. The basic rules are as follows:

Buy: when the price tests the lower band and closes above it, buy at the opening of the next bar. Close the position when the price closes above the moving average.

Sale: when the price tests the upper band and closes below it, sell at the opening of the next bar. Close the position when the price closes below the moving average.

All tests are performed with an initial capital of $ 10000, on EURUSD, for the period from 01-01-2008 to 01-01-2012 and for different time frames (M15, H1, H4 and D1). Volume of trade = 1 mini lot ($ 10K).

The second way to use Bollinger bands becomes more and more popular in recently published books about Forex. The first time I saw one such strategy, it was in the book “The Little Book of Currency Trading: How to Make Big Profits In The World of Forex” by Kathy Lien. By the way, I recommend all books written by this author. The strategy is to trade the breakout of bands and has the advantage of integrating the component of volatility that makes the same strategy can be applied unchanged to many currency. The basic rules of this second strategy are as follows:

Buy: when the price breaks through the upper band and closes above it, buy at the opening of the next bar. Close the position when the price closes below the moving average.

Sale: when the price breaks through the lower band and closes below it, sell at the opening of the next bar. Close the position when the price closes above the moving average.

The goal of the first backtest is to compare these two strategies based on Bollinger Bands. Using the default settings (20, 2.0), produces $ -210 for the first strategy and $ 2687 for 2nd. The optimization works better for the second strategy in all time frames; ($ 4335, $ 4689, $ 3431, $ 2801) versus ($ 1054, $ 1551, $ 930, $ 226). We can say that the strategy of the breakout of Bollinger Bands is definitely better than the bounce on the bands. At least it was during the period 2008-2011 for the EURUSD.

If you like this website, please recommend it to your friends. If you want it to be better, please leave us a feedback.

Read More…]]>Trading is much like the practice of martial arts. To succeed, you need discipline, perseverance and a lot of practice. You’ll be lucky if you could find a good mentor (the master). The analogy becomes even more striking when I think to the concept of the great masters. In the world of trading, we think of legends like Charles Dow, W. D. Gann, Ralph Nelson Elliot, and among those who still alive, John Bollinger, Ed Seykota, Larry Williams, Joe DiNapoli and others.

When you read a book of these great masters, because you do not have the chance to meet them and even less have them as a mentor, you feel their great wisdom, talent and you are touched by great humility. I recently started reading the book by Joe DiNapoli and then I found a series of interviews with him on youtube. This guy symbolizes the great masters of modern times.

That’s why I decided to add a page of quotations. Whenever I read a book and find a quotation that inspires me, I’ll write it in this page.

If you like this website, please recommend it to your friends. If you want it to be better, please, leave us a feedback.

Read More…]]>Some time ago when we were started to look at Forex-Trading, we had read a hundred of books, spend many hours online looking for information and especially looking for a trading system. We found several, from simple to complex. But few sources show the validity of the systems they have. What we are left unsatisfied and especially worried to use a system which we don’t know the validity. So, armed with our programming skills, we will try to fill this void by testing on Metatrader 5 trading systems that seem interesting.

The systems we will test will be taken from books, websites (forums, blogs, …) or proposed by our readers. We will whenever necessary references for those who want to dig a little more. Our goal is to test the maximum allowed by our free time.