Opening Range Breakouts (Amibroker And Tradestation Code)

The original strategy can be found by clicking here.

The test in plain English:

  1. We use 1-minute bars.
  2. We optimize by using the high from the open (0830 local time) and measure the high from open every hour.
  3. We exit on the close of the day.

Amibroker code:

oddis = Optimize(“Hour”,090000,090000,140000,10000);
MyHigh=ValueWhen(TimeNum()==oddis,HighestSince(TimeNum()==083000,High));

Buy = Cross(H,myhigh) AND TimeNum()>oddis ;  //buy when the close breaks above the high from our defined period
BuyPrice=Close;
Sell = TimeNum()==150000 OR Day() != Ref(Day(),1) ;
SellPrice=Close;

Tradestation code:

{
Strategy 93 - Opening Range Breakouts
Calculate highest high from open until the specified time of the trading day
For the rest of the trading day watch the price. 
If the price crosses over the previously calculated higehest high, buy and hold till the close.

Before running the backtest, ensure that data series with interval 5 minutes (or event 1 minute) is loaded for the symbol.
Do not forget to set Display - Time-zone: Exchange for the data series.
}

Inputs:
	TimePoint(1030);
	
Vars:
	HighestHigh(0);
	
	
if Date <> Date[1]  then HighestHigh = High;

if Time <= TimePoint then begin
	if High > HighestHigh then HighestHigh = High;
end;

if Time > TimePoint then begin
	if High > HighestHigh then buy this bar on close;
end;

Print(Date,Time,HighestHigh);

Setexitonclose;