How to eliminate look-ahead bias(future looking) in price action code

Hi Team. I have a code in which i am trying to entry at a limit price after a condition is met

todayO = TimeFrameGetPrice("O" , inDaily , 0) ; 

buycondition = close>todayO*1.02 and Low<Min(Ref(close , -1) , Ref(high , -1)*0.995)  and timenum>93000 ;

entryprice = Min(Ref(close , -1) , Ref(high , -1)*0.995)
Buy = buycondition ;

// Sell code is simple ( EOD exit) 
// No other condition or indicator is used

// No trade delays used if low of the current bar is below my limit price. i enter at market( kinda a limit order)

This code is showing exceptional results in backtest over a bunch of equities...

My Only question is--- i am using close to check whether i am above 2% from today's open and using a limit order in the same bar to achieve a better entry..

Isn't there a look ahead(future looking ) bias in my code as the close of the bar is not known in advance and i am entering with a limit price in the same bar( no trade delays)

The code preview does not show any look-ahead bias. But i feel i am doing something wrong.

Please tell is this tradeable????

what is the time frame that you using to backtest this?

I did not test the code to check if there are other issues, but from looking at it, if buy condition involves a decision with the bar close price, then buy price should also be the closing price.

Code check will only pick up issues like ref(c,2) where your looking ahead in the function.

As far as using buyprice it’s on the AFL creator to make sure the logic doesn’t have any look ahead bias.

From your explanation your only entering guaranteed winning trades. Your entering only after you know it’s up 2% and at a random price below it.

I am using a 15 min timeframe to test it.

Yes true. I figure that is the issue the code knows that the close of the bar would be eventually over 2% and i am entering somewhere near the lows of the same bar. Hence the performance is inflated