Backtesting Code: Buy at Opening and Sell at closing

What is the code for backtesting a simple strategy of buying at the opening of the day and selling at the closing of the same day?

@Rachana_Dhanraj, if you can mention the underlying logic based on which you would want to buy or sell that stock, it can be backtested in Streak.

Ah! Thanks for that insight. I’ll now put a supporting condition. I am just curious to know the profit percentage if a share is bought everyday at opening and sold at closing without any additional conditions.

So you can do this by using the condition, mentioned below

Entry: Close(0) higher than 0

This logic will work because the price of any stock cannot be less than Zero. The exit condition is not required since all positions for MIS strategies are automatically squared off after the close of the trading session.

Hope this helps.

In PI,
What would be the code to create a set that contains the 2nd 15minute candle of every day on a chart of a particular stock.?
So that the data of that set can be used to backtest some startegy.