Skip to main content

SPEED TRADING SYSTEM for Amibroker (AFL)

samr12 about 16 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 2)
  • Tags:
    trading system, amibroker

In “Improve Your Trading System With Speed,” Gomu Vetrivel presents a method to improve trading system performance by choosing only the entry signals that occur when price speed increases. Speed is defined as the absolute difference between today’s and yesterday’s closing prices.

Coding such speed-enhanced trading systems is easy in AmiBroker Formula Language (AFL). Ready-to-use code is presented here. To demonstrate, the code uses a simple 10-/five-bar moving average crossover as a base system (as in Vetrivel’s article); however, users can replace the entry/exit rules (the first four lines of the code) by any other system of their choice to check whether speed-filtering helps.

Indicator / Formula

Copy & Paste Friendly
// Base trading system
Buy = Cross( C, MA( C, 10 ) );
Sell = Cross( MA( C, 5 ), C );
Short = Cross( MA( C, 10 ), C );
Cover = Cross( C, MA( C, 5 ) );
// Speed calculation
Speed = abs( C - Ref( C, -1 ) );
// SpeedUp is boolean, which is true when speed increases
SpeedUp = Speed > Ref( Speed, -1 );
SpeedDown = Speed < Ref( Speed, -1 );
// these statements modify trading system rules
// to enter long/short only when speed increases
// (hypothesis 1)
Buy = Buy AND SpeedUp;
Short = Short AND SpeedUp; 

1 comments

Leave Comment

Please login here to leave a comment.