Back testing of scrips for intraday trading

Request someone to help me in coding of the following buying and selling strategy on intraday basis

Scrip: BANKNIFTY JULY 19 FUTURES

Strategy to buy

when price closes above high price of FIRST 45 minutes of the day

Strategy to Sell

when price closes below low price of FIRST 45 minutes of the day

StopLoss at 100 points

Target at 100 points

Trade - Intraday

Square off at 15.15 Hrs

Thanks in advance

Siva Prasad

1 Like

What is the time frame of candlestick you want to close above 45 Minutes Opening Range?

1 Minute Candle or 5 Minute Candle or which one?

5 Minutes candle please.

As per your explanation of the strategy, I ran backtesting for BANKNIFTY JULY 19 FUTURES in Zerodha Streak.

For Buy Entry -
When 5 minutes candle gives close above 45 Minutes Opening Range, then it is a buy.

For Stop Loss -
I used 0.40% of entry price (which comes around 100-120 Points)

For Target -
I used 0.40% of the entry price (around 100-120 Points).

The strategy automatically exits the position at 3:15 PM (MIS Order) if the target or stop loss is not reached. Also, no new entry is taken after 3:15 PM.

I am attaching the screenshot of all conditions below -

The backtesting results are (Without Brokerage & Other Charges)-

The backtesting results are (With Brokerage & Other Charges)-

For Sell Entry -
When 5 minutes candle gives close below 45 Minutes Opening Range, then it is a sell.

For Stop Loss -
I used 0.40% of entry price (which comes around 100-120 Points)

For Target -
I used 0.40% of the entry price (around 100-120 Points).

The strategy automatically exits the position at 3:15 PM (MIS Order) if the target or stop loss is not reached. Also, no new entry is taken after 3:15 PM.

I am attaching the screenshot of all conditions below -

The backtesting results are (Without Brokerage & Other Charges)-

The backtesting results are (With Brokerage & Other Charges)-

You can backtest yourself too by experimenting with other conditions and putting in more complex conditions.
The platform is Zerodha Streak (http://tiny.cc/StreakByZerodha). They let you backtest strategies without needing to code them.

I think their support team is also active on this forum. @Streak . You can ask them queries if you have any.

1 Like

Very nice and useful answer, thank you.

1 Like

But you have done coding in reverse strategy for Buy and Sell obligation.
Please checkout.
Thank you.

@RN2234

No No. I have checked. They are correct.

For selling, I used the condition - When Opening Range’s Low Price crosses above close price of 5 minutes candle.
For buying, I used the condition - When Opening Range’s High Price crosses below close price of 5 minutes candle.

I used Opening Range as the primary input and 5 Minutes candle as secondary input.

That’s correct. It is another way of saying

Buy: when Close crosses above Opening Range (High, 45 min)

Essentially both statements are the same.

1 Like

Sorry I little bit confused, your coding correct.