Give me the code to backtest

Hellow,
I want a simple code to backtest in PI, that buys a stock at market opening price and sells at profit of Rs.8 i.e.( Buying price + 8).
Please help.

The above given price based conditions gives the continues buy and sell signals on the each and every day candle and it is not possible to backtest the above condition.

Hi, I can request you to please give me a code to test in Pi for

Buy when 10ema crossover 200ema and
sell when 200ema crossover 10ema

But the addition in this strategy would be, when the buy happen and the different between the two EMA reaches 5%, then the position gets squared off

Sir can you please send me the code for his

Sir let us take a case ;

Example
Buy happen as
10ema = 100 when it crossover 200ema =99.99
10emam reaches 106 and 200ema reaches 101, the position gets squared off

Now there is not position, and after some time Sell position happen as
10ema = 103 and 200ema is 103.1
10ema reaches 95 and 200ema =100, the position gets squared off.

and if the crossover happen before the 10ema reaches 5% then the position is reversed

I want to do only one trade at 9:15 am and exit when it ups to Rs. 8