Which Oscillating Indicator Is The Best For Trading Strategies? (Amibroker And Tradestation Code)

The relevant article can be found by clicking here.

Below is the Amibroker code for the tests we did:

Williams %R:

oddis=Optimize(“days”,2,2,10,2);
oddis1=Optimize(“Entry level”,-85,-90,-65,5);
oddis2=Optimize(“Exit level”,-15,-90,-65,5);
Williams=( ( HHV(H,oddis) – Close ) / ( HHV(H,oddis) – LLV(L,oddis) ) ) * -100 ;

Buy = Cross(oddis1,Williams);
BuyPrice=Close;
Sell = Cross(williams,oddis2);
SellPrice=Close;

{
Williams %R indicator (Strategy 92A)
Calculate Williams %R indicator.
Enter long position when Williams %R goes below -85.
Exit the long position when Williams %R goes over -15.
You can optimize input parameters as described here: https://help.tradestation.com/09_01/tswfo/topics/optimize_strategy_in_tradstation.htm
}

Inputs:
	Lookback(2),
	EntryLevel(-85),
	ExitLevel(-15);
	
Vars:
	Indicator(0);
	
Indicator = (Highest(High, Lookback) - Close) / (Highest(High, Lookback) - Lowest(Low, Lookback)) * -100;

if Indicator cross under EntryLevel then buy this bar on close; 
if Indicator cross over ExitLevel then sell this bar on close;

RSI:

oddis=Optimize(“days”,2,2,10,2);
oddis1=Optimize(“Entry level”,15,10,40,10);
oddis2=Optimize(“Exit level”,85,60,90,10);

Buy = Cross(oddis1,RSI(oddis));
BuyPrice=Close;
Sell = Cross(RSI(oddis),oddis2);
SellPrice=Close;

{
RSI indicator (Strategy 92B)
Calculate RSI indicator.
Enter long position when RSI goes below 15.
Exit the long position when RSI goes over 85.
You can optimize input parameters as described here: https://help.tradestation.com/09_01/tswfo/topics/optimize_strategy_in_tradstation.htm
}

Inputs:
	Lookback(2),
	EntryLevel(15),
	ExitLevel(85);
	
Vars:
	Indicator(0);
	
Indicator = RSI(Close, Lookback);

if Indicator cross under EntryLevel then buy this bar on close; 
if Indicator cross over ExitLevel then sell this bar on close;

IBS:

oddis=Optimize(“days”,3,1,10,1);
oddis1=Optimize(“Entry level”,0.4,0.05,0.35,0.05);
oddis2=Optimize(“Exit level”,0.6,0.65,0.95,0.05);
ibssnitt=MA(ibs,oddis);

Buy = Cross(oddis1,ibssnitt);
BuyPrice=Close;
Sell = Cross(ibssnitt,oddis2);
SellPrice=Close;

{
IBS indicator (Strategy 92C)
Calculate IBS - in bar strength indicator.
Enter long position when IBS goes below 0.4.
Exit the long position when IBS goes over 0.6.
You can optimize input parameters as described here: https://help.tradestation.com/09_01/tswfo/topics/optimize_strategy_in_tradstation.htm
}

Inputs:
	Lookback(3),
	EntryLevel(0.4),
	ExitLevel(0.6);
	
Vars:
	Indicator(0);
	
Indicator = Average((Close - Low)/(High - Low), Lookback);

if Indicator cross under EntryLevel then buy this bar on close; 
if Indicator cross over ExitLevel then sell this bar on close;

Stochastics:

oddis=Optimize(“days”,2,2,10,2);
oddis1=Optimize(“Entry level”,10,10,40,5);
oddis2=Optimize(“Exit level”,70,60,90,5);

Buy = Cross(oddis1, StochK(oddis,oddis)) ;
BuyPrice=Close;
Sell = Cross(StochK(oddis,oddis),oddis2);
SellPrice=Close;

{
Stochastics indicator (Strategy 92D)
Calculate Stochastics indicator.
Enter long position when Stochastics SlowK goes below 10.
Exit the long position Stochastics SlowK goes over 70.
You can optimize input parameters as described here: https://help.tradestation.com/09_01/tswfo/topics/optimize_strategy_in_tradstation.htm
}

Inputs:
	Lookback(2),
	EntryLevel(10),
	ExitLevel(70);
	
Vars:
	FastK(0), FastD(0), SlowK(0), SlowD(0), Result(0),
	Indicator(0);
	
Result = Stochastic(High, Low, Close, Lookback, Lookback, Lookback, 1, FastK, FastD, SlowK, SlowD);
Indicator = SlowK;

if Indicator cross under EntryLevel then buy this bar on close; 
if Indicator cross over ExitLevel then sell this bar on close;

Bollinger bands:

oddis=Optimize(“days”,2,2,10,2);
oddis1=Optimize(“Entry level”,1,1,2,0.2);
oddis2=Optimize(“Exit level”,1,1,2,0.2);

Buy = Cross(BBandBot(Close,oddis,oddis1),Close) ;
BuyPrice=Close;
Sell = Cross(Close,BBandTop(Close,oddis,oddis2));
SellPrice=Close;

{
Bollinger bands indicator (Strategy 92E)
Calculate Bollinger bands indicator.
Enter long position when Close goes below Bollinger band bottom.
Exit the long position when Close goes above Bollinger band top.
You can optimize input parameters as described here: https://help.tradestation.com/09_01/tswfo/topics/optimize_strategy_in_tradstation.htm
}

Inputs:
	Lookback(3),
	EntryLevel(-1),
	ExitLevel(1);
	
Vars:
	BBtop(0),
	BBbot(0);
	
BBbot = BollingerBand(Close, Lookback, EntryLevel);
BBtop = BollingerBand(Close, Lookback, ExitLevel);

if Close cross under BBbot then buy this bar on close; 
if Close cross over BBtop then sell this bar on close;

WilliamsVixFix

oddis=Optimize(“days”,10,2,10,2);
oddis1=Optimize(“Entry level”,96,90,99,1);
oddis2=Optimize(“Exit level”,4,1,10,1);
HighestClose=HHV(close,oddis);
WilliamsVixFix=(((HighestClose-Low)/HighestClose)*100);

Buy = PercentRank(WilliamsVixFix,22) > oddis1 ;
BuyPrice=Close;
Sell = PercentRank(WilliamsVixFix,22) < oddis2 ;
SellPrice=Close;

{
Williams VIX fix indicator (Strategy 92F)
Calculate Williams VIX fix indicator.
Go long if the WilliamsVixFix closes high on the 22-day PercentRank. 
We use 96% as threshold and entry on the close.
Exit if the WilliamsVixFix closes low on the 22-day PercentRank.
We use 4% as threshold and exit on the close.
You can optimize input parameters as described here: https://help.tradestation.com/09_01/tswfo/topics/optimize_strategy_in_tradstation.htm
}

Inputs:
	Lookback(10),
	PercentRankLookback(22),
	EntryLevel(96),
	ExitLevel(4);
	
Vars:
	index1(0),
	index2(0),
	highestClose(0);

Arrays:
	WilliamsVixFix[](0);

Array_setmaxindex(WilliamsVixFix, PercentRankLookback+1);

for index1 = 0 to PercentRankLookback Begin
	highestClose = 0;
	for index2 = 0 to Lookback-1 Begin
		if Close[index1 + index2] > highestClose then 
			highestClose = Close[index1 + index2];  
	end;
	WilliamsVixFix[index1] = (((highestClose - Low[index1]) / highestClose) * 100);
end;

if (Marketposition = 0) and (PercentRankAB(WilliamsVixFix, PercentRankLookback) > EntryLevel) then buy this bar on close;
if (PercentRankAB(WilliamsVixFix, PercentRankLookback) < ExitLevel) then sell this bar on close;