Skip to main content

Four Model for Amibroker (AFL)

XavierJohn about 14 years ago Amibroker (AFL)

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

Four Model by Martin Zweig’s
See Zweig Book: Martin Zweig’s Winning with New IRAs, pages 117-128

Model was designed to be applied toa weekly chart of the Value Line Composite index ( VLCI)
Program uses a the weekly close of the VLCI to initate trades
Buy if the weekly close of the VLCI rises 4% or more from its lowest close ( since the last sell signal)
Sell if the weekly close of the VLCI falls 4% or more from its highest close ( since the last buy signal)

Indicator / Formula

Copy & Paste Friendly
// Four Model by Martin Zweig's
// See Zweig Book: Martin Zweig's Winning with New IRAs, pages 117-128
// Translated to AFL by Xavier 
// Model was designed to be applied toa weekly chart of the Value Line Composite index ( VLCI)
// Program uses a the weekly close of the VLCI to initate trades
// Buy if the weekly close of the VLCI rises 4% or more from its lowest close ( since the last sell signal)
// Sell if the weekly close of the VLCI falls 4% or more from its highest close ( since the last buy signal)

perOffLo = Param("% off lowest close", 4,1, 10);
perOffHi = Param("% off highest close", 4,1, 10);
trend = 0;
HC = LC = C[0];

for( i =0; i < BarCount ; ++i)
{
	if ( trend == 0)
	{
		if (((C[i] - LC) / LC) >= (perOffLo / 100))
		{
			trend = 1;
		}
		if (((HC - C[i] ) / HC) >= (perOffLo / 100)) 
		{
			trend = -1;
		}
	}
	else if ( trend == 1 AND ((HC - C[i]) / HC) >= (perOffHi / 100)) 
	{
		Sell[i] = 1;
		trend = -1;
		LC = C[i];
	}
	else if ( trend == -1 AND ((C[i] - LC) / LC) >= (perOffLo / 100)) 
	{
		Buy[i] = 1;
		trend = 1;
		HC = C[i];
	}
	
	if ( C[i] < LC) LC = C[i];
	if ( C[i] > HC) HC = C[i];
}

2 comments

almost 14 years ago

I test with
Value Line Arithmetic Index,RTH (^VAY)
yahoo finance.

It can be used as a signal to buy other stocks.

Leave Comment

Please login here to leave a comment.