5 minute candle strategy trade

how to write an algo for the following:

  1. buy when latest 5 minute candle breaks days high by 0.15%.
  2. sell when latest 5 minute candle breaks days low by 0.15%

how to decide a day low or high? did you mean yesterday low price ,a running day low price will always changes .

Sir i want to buy after the close of first 5 minute candle.
Lets say i am considering intraday 5 min chart. I want to buy when rsi is above 50 and latest 5 min candle has crossed today’s high by 0.15%.

so,algo is comparing only days first 5m candle.as per your screenshot ,you will have 2 positions ,since rsi satisfies > 50 ,when to close a position ?
based on rsi ,or order percentage ?

Sir i want to buy after the following conditions are met:

  1. wait for the first 5 minutes candle to end ie 9.20am.
  2. check weather rsi is above 50.
  3. weather macd is above zero line.
  4. if conditions 2 and 3 are met then I will buy only when latest candle has crossed days high by more than 0.15%.

im writing in tradingview pine ,for pi tradescript , there is no api avialable to get chart 5m days first candle ,its not possible in pi .
reagarding condition 4 ,is lasterst new candle ,whole should be above to previous candle ,only close price ?

Regarding condition 4 , the high of latest candle should be higher than that days high.
Say from 9:15 am to 10 am high is 100.00 and 10:05 am candle crosses above 100.15 (0.15%) above) than i will buy. In short I will buy when the latest 5 min candle breaks today’s high by 0.15%.
Also sir when i am backtesting there are many trades happening for a strategy.
I want to set condition in algo where only one trade should take place in one day after that it should stop for that particular stock.

I made the same script yesterday for the trading view…only condition does not add that 0.15% high break …