Mass Index Trading Strategy (Amibroker And Tradestation Code)

The original article can be found here.

Trading rules in plain English:

  • We make a 5-day RSI of the MASS Index indicator
  • We buy at the close when the RSI closes below 25
  • We sell at the close when the RSI closes above 75

Amibroker code:

diff = H - L;
ediff = EMA( diff, 9 );
eediff = EMA( ediff, 9 );
MassIndex= Sum( ediff/eediff, 18 );
 
RSIMI=RSIa(MassIndex,5);

Buy= RSIMI<25 ;
buyPrice=Close;
Sell= RSIMI>75;
sellPrice=Close ;

Tradestation code:

{
Strategy - Mass index trading
https://www.quantifiedstrategies.com/lessons/mass-index-trading-strategy-amibroker-code/
}

Inputs:
	EmaLookback(9),
	RsiLookback(5),
	SumLength(18),
	BuyTreshold(25),
	SellTreshold(75);
	
Vars:
	RsiMi(0);
	
RsiMi = RSI(MassIndex(EmaLookback, SumLength), RsiLookback);

if RsiMi < BuyTreshold Then
	buy this bar on close;

if RsiMi > SellTreshold Then
	sell this bar on close;