Ultimate Oscillator (Amibroker And Tradestation Code)

The original article can be found here.

Amibroker code:

Default settings:

Buy= Cross(40,Ultimate(7,14,28)) ;
buyPrice=Close;
Sell= Cross(Ultimate(7,14,28),50);
sellPrice=Close ;

Optimization:

oddis=Optimize(“First setting”,2,2,10,2) ;
oddis1=Optimize(“Second setting”,6,6,14,2) ;
oddis2=Optimize(“Third setting”,14,10,20,2) ;

Buy= Cross(30,Ultimate(oddis,oddis1,oddis2) ) ;
buyPrice=Close;
Sell= C>Ref(H,-1);
sellPrice=Close ;

Tradestation code:

{
Strategy 121A - Ultimate oscillator
}

Inputs:
	LookbackFast(7),
	LookbackMed(14),
	LookbackSlow(28),
	BuyTreshold(0.4),
	SellTreshold(0.5);

Vars: uo(0);

uo = UltimateOscillator(LookbackFast, LookbackMed, LookbackSlow);

if uo cross under BuyTreshold Then
	buy this bar on close;
	
if uo cross over SellTreshold then 
	sell this bar on close;



{
Strategy 121B - Ultimate oscillator
Optimized settings
}

Inputs:
	LookbackFast(2),
	LookbackMed(6),
	LookbackSlow(14),
	BuyTreshold(0.3);

Vars: uo(0);

uo = UltimateOscillator(LookbackFast, LookbackMed, LookbackSlow);

if uo cross under BuyTreshold Then
	buy this bar on close;
	
if Close > High[1] then 
	sell this bar on close;