Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

/*AMIBROKER: THE MOVING TREND

Implementation of the moving trend indicator as described by William Rafter in his


article in this issue, "The Moving Trend," is very straightforward AND simple in
AmiBroker 4.20. Its built-in LinearReg function allows calculation of the moving
trend indicator in a single line of code.

In Listing 1 given here, you will find the formula that replicates the display of
moving averages versus moving trends, as presented in Rafter's article.

LISTING 1*/
MovTrend20 = LinearReg( Close, 20 ); // calculate moving trend
// plot moving trend, moving average and price bars
Plot( MovTrend20, "MovTrend-20", colorRed, styleThick );
Plot( MA( Close, 20 ), "MA-20", colorBlue, styleThick );
Plot( Close, "Price", IIf(Close > Open, colorDarkGreen, colorDarkRed), styleBar) ;
//It is also very easy to produce the surrogate bar chart from moving trend values.
Appropriate code is included here in Listing 2.

You might also like