Here is a simple Full Gap Open Range Strategy for intraday traders to trade the big gap ups and gap downs using open range breakout. And more important strategy is back-testable.

**Full Gap:** Today’s open is outside the range of yesterday high or low .i.e. today’s open should be higher of yesterday’s high or lower of yesterday’s low.

**Open Range:** Calculate the range (High and Low) after-market open till certain time e.g . If we want calculate the range till 9.30a.m ( to determine high-low range for the first 15min after market open).

**Rules**

**ORB Range** : First 15min Range High and Range Low is Computed

**Buy** : If Gap Up or Gap Down and the Range High Breaks (First 15min) breaks on intraday basis

**Short** : If Gap Up or Gap Down and the Range Low Breaks (First 15min) breaks on intraday basis.

**Sell** : Exit Longs if the target Range High * (1+target/100) is met on intraday basis or exit at 3:15p.m if target is not met. **Stop Loss** : Yesterday Low

**Cover** : Exit shorts if the target Range low * (1-target/100) is met on intraday or exit at 3:15p.m if target is not met. **Stop Loss** : Yesterday High

**GapORB – Amibroker AFL Code**

https://gist.github.com/35dc4972bd957445918a

**Assumptions**

1)Which Instrument you had backtested :BankNifty

2)What is the time frame used? :5Min

3)Commissions – Rs 100 per leg.

4)How many years the data got backtested? – 3Yrs

Could you please elaborate how do we handle a scenario when both Range High/low breaks on the same candle? Will it take the 1st trade only? Or both buy/.short trades?

when we are entering on the range breakout, we should consider the buy/short price at value when it breaks the level right? Then, why close price is mentioned as Buy/short price? As per the below code, i assume we are not entering on the price breakout, we need to wait for the candle close above/below the range and only when this condition satisfies we need to enter.?

BuyPrice=ValueWhen(Buy,C);

ShortPrice=ValueWhen(Short,C);

CoverPrice=ValueWhen(Cover,C);

SellPrice=ValueWhen(Sell,C);

For calculation Close is good option rather then the range price. You can modify the code as per the requirement

Thanks for sharing your strategy.

Could you please clarify terms, TARGET RANGE HIGH & TARGET in the Exit Long Formula?

Let say, first 15 min range is 10 points, what is the target please…

Thanks for your valuable time.

Range High -Low : first 15 min high low pice and if you want you can change it

Currently target has been set 2.5% after entry .However you can modify the target say 1 %,1.5% etc …

Can I explore this AFL for knowing which stocks are available for Buy and Sell ?

Currently Exploration is not added in the code However you can scan the stock using SCAN button

Does this strategy apply to Nifty? at what % of volatality it wii work best? pl. define high & Low volatalty % range for Nifty

I don’t have nifty data .May be you can back test this strategy nifty and any other high beta stock

Thanks for the strategy & afl code! I’d be interested in INTRADAY methods & AB code e.g. (a) Pivot Levels

(b) News Trading (c) Scalping (d) Range Trading (e) Pairs Trading…. Best Regards, Amarjit

An extension for the strategy maybe:

if “n” trades in LONG direction are losing for the day then stop trading for the day

if “n” trades in SHORT direction are losing for the day then stop trading for the day

I am new with AB, how would I code in afl the above rule?

many thanks,

Amarjit

Has anyone tested this strategy with any other index or stock (other than Bank Nifty) where it gives similar or better results? I tested with 12-13 Nifty stocks (cash segment data) with last 7 years of data (5 min time frame). The maximum profit with an initial capital of 250000 was around 60000, which is not good enough to deploy in practice. Average brokerage per trade was 100.

1.) Can You Pls mention the year on which backtest result is attached.

2.) Sell = Cross(H,RangeHigh*(1+target/100)) OR Cross(DayH,L) OR TimeNum()>151500 ;

2. if i have buy position than STOPLOSS is yesterday Low,but you mentioned here Cross(DayH,L) i.e previous day high crosses the cur day low. is this right?

Is this possible to create AFL Code for Stopping Volume and Is there any VSA and OI combined strategies?

Kindly Reply.

HI,

Regarding the Sell and cover as mentioned below is not clear.

Sell = Cross(H,RangeHigh*(1+target/100)) OR Cross(DayH,L) OR TimeNum()>151500 ;

Cover = Cross(RangeLow*(1-target/100),L) OR Cross(H,DayL) OR TimeNum()>151500 ;

Can you please explain why “Cross(DayH,L)” is mentioned for sell ?

the the condition is evaluated true, dont you think it will result in multiple trades for the same script every time the conditino is satisfied as true

You can control the multiple orders from your Algo Coding Block in AFL