Open Range Breakout is a simple strategy that monitors the first 5min / 15min / 15min / 30min / 60min range from the start of the market. From the opening high range and low range is calculated for the specified timeframe. Most of the AFL code found on the internet is either buggy or not suitable for building back-testable trading systems. To solve this issue we are releasing a prototype for ORB – Open Range Breakout Levels. On top of this indicator now traders can build backtestable trading systems.
Recommended Timeframe to Run this strategy: 1min or 5min charts (Higher timeframe may or may not yield desired results)
By default, the code uses a 60min range breakout from the market open. However, Parameters can be changed from the Parameter window. Currently Open Range breakout options are available for 5min / 15min / 15min / 30min / 60min ranges. However, if someone needs a customized ORB range then code customization needs to be done accordingly.
Code will start plotting the Open Range values only if the Open Range timeframe is completed else nothing will be plotted. For example for an Open Range value of 60min. The plot will start only from 10:15:00 onwards for NSE Futures instruments and will start from 11:00:00 onwards for MCX futures instruments automatically.
The code works well with Illiquid scripts. Quick AFL is turned off to compute for all the bars.
Code Snippet: ORB – Open Range Breakout Levels – Amibroker AFL Code
//Better Version of Open Range Breakout
//Coded By Rajandran R - www.marketcalls.in
//Created Date - 04 Dec 2018
//Recommended Timeframe to Run this strategy : 1min or 5min charts
//Higher timeframe may or may not yield desired results
_SECTION_BEGIN("Open Range Breakout");
SetBarsRequired(-2,-2); //Turn Quick AFL Off
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g ", Ref(O,-1), Ref(H,-1), Ref(L,-1), Ref(C,-1)));
SetChartOptions(0 , chartShowArrows | chartShowDates);
Plot(Close,"Candle", colorDefault, styleCandle);
orb = ParamList("ORB Range", "5min|10min|15min|30min|60min",4);
newday = Day() != Ref(Day(),-1); //check if new day or not
starttime = ValueWhen(newday,TimeNum());
//5min ORB
if(orb == "5min")
{
IBendtime = starttime+500;
minh = ValueWhen(newday,TimeFrameGetPrice("H",in5Minute));
minl = ValueWhen(newday,TimeFrameGetPrice("L",in5Minute));
}
//15min ORB
if(orb == "10min")
{
IBendtime = starttime+1000;
minh = ValueWhen(newday,TimeFrameGetPrice("H",in5Minute*2));
minl = ValueWhen(newday,TimeFrameGetPrice("L",in5Minute*2));
}
//15min ORB
if(orb == "15min")
{
IBendtime = starttime+1500;
minh = ValueWhen(newday,TimeFrameGetPrice("H",in5Minute*3));
minl = ValueWhen(newday,TimeFrameGetPrice("L",in5Minute*3));
}
//30min ORB
if(orb == "30min")
{
IBendtime = starttime+3000;
minh = ValueWhen(newday,TimeFrameGetPrice("H",in5Minute*6));
minl = ValueWhen(newday,TimeFrameGetPrice("L",in5Minute*6));
}
//60min ORB
if(orb == "60min")
{
IBendtime = starttime+6000;
minh = ValueWhen(newday,TimeFrameGetPrice("H",inhourly));
minl = ValueWhen(newday,TimeFrameGetPrice("L",inhourly));
}
printf("%g",IBendtime);
DayOpen = TimeFrameGetPrice("O",inDaily);
DayHigh = TimeFrameGetPrice("H",inDaily);
DayLow = TimeFrameGetPrice("L",inDaily);
ORBH = IIf(TimeNum() < IBendtime, Null ,minh);
ORBL = IIf(TimeNum() < IBendtime, Null, minl);
Plot(ORBH,"ORBH",colorBlue);
Plot(ORBL,"ORBL",colorred);
Do i need to change ORB Range 60 min to 30 or 15 min ?, what is your expert recommendations ?
Hi.. sir.. can u please add the option to make the ORB lines thicker.. it’s too thin.. it’s hard to see..
Thanx in advance..
Kindly make the AFL backtestable. Thanks.
sir, a am using amibroker can you give me afl for trading.
sir can you please help to create complete code for buy and sell event with fixed target price ?
hi how to add a filter for range of first candle , ??
Sir, can you developed RENKO based afl????