Need codes for my logic

i’m just checking bank nifty to code following logic / condition

  1. buy at close price

  2. sell at next day (open price+200) OR (open price-200), if not possible, sell at close price

3.if sold at (open price+200), then again initiate buy at spot price and check for 2nd condition

4.if sold at (open price-200), then again initiate short sell at spot price and check for 2nd condition


day 1: close price 16530

day 2: opens at 16600

at 11:30 , if spot price is < 16400, i will trigger , booking LOSS and initiate SHORT SELL at 16400 (say)


at 11:30 , if spot price is > 16800, i will trigger , booking PROFIT and initiate BUY at 16800 (say)

again from 16400 or 16800, will be checking for +200 or -200 points movement, if any one achieved, we hit or square off position, if nothing is achieved, then square off at close price.

again buy at close price for next day trade

What if next day open is -1200?

+200 / -200, from the opening price.
then, its obviously, 16530-1200 = 15330 is opening price and i check from 15330 +200 or 15330-200 for criteria.
i know, its huge loss / profit scenario…