SetTradeDelays :: Backtest vs. Real-Time Trading

I have been struggling a while to figure out how SetTradeDelays should be set when migrating from Backtesting to Real-Time trading.

Here I am using BB's as signal to enter a trade on the next bar Open, which I understand.

/////// BACKTEST 

// Buy next bar on Open...
SetTradeDelays( 1, 1, 1, 1 );  

// Simulate LMT Order
BuySignal = Cross( Close, BBandBot( Close, 20, 2 ) );
BuyPrice = Min( Open, Ref( BBandBot( Close, 20, 2 ), -1 ) );
Buy = Buy AND BuyPrice > Low;

The problem is I am unclear how to "migrate" this code to real-time trading. That is, I am unclear on how to emulate the backtest code faithfully.

The first option is to try to "mimic" what I am doing in the backtest and do the following. Here SetTradeDelays are set to (1, 1, 1, 1)

/////// REAL-TIME TRADING :: OPTION 1


SetTradeDelays( 1, 1, 1, 1 );  

BuySignal = Cross( Close, BBandBot( Close, 20, 2 ) );
BuyPrice = Min( Open, Ref( BBandBot( Close, 20, 2 ), -1 ) );
Buy = Buy AND BuyPrice > Low;

if ( LastValue( Buy ) ) {      
   
	Price = LastValue( BuyPrice );
	Shares = LastValue( Round( ( PosSize / Price ) / 5 ) * 5 );	  
	  
	if ( LastValue( TimeNum() ) >= 093000 && LastValue( TimeNum() ) <= 160000 ) {	  
		parentID = ibc.PlaceOrder(Name(), "BUY", Shares, "LMT", Price, 0, GTDTime, True ); 
 	}	 
}

The next option is to set Trade Delays to (0, 0, 0, 0) and do the following since this is "real-time" trading:

/////// REAL-TIME TRADING :: OPTION 2

SetTradeDelays( 0, 0, 0, 0 );  

BuySignal = Cross( Close, BBandBot( Close, 20, 2 ) );
BuyPrice = Min( Open, Ref( BBandBot( Close, 20, 2 ), -1 ) );
Buy = Buy AND BuyPrice > Low;

if ( LastValue( Buy ) ) {      
   
	Price = LastValue( BuyPrice );
	Shares = LastValue( Round( ( PosSize / Price ) / 5 ) * 5 );	  
	  
	if ( LastValue( TimeNum() ) >= 093000 && LastValue( TimeNum() ) <= 160000 ) {	  
		parentID = ibc.PlaceOrder(nm, "BUY", Shares, "LMT", Price, 0, GTDTime, True ); 
 	}	 
}  

The question is which option emulates the backtest code more faithfully? Which option is best? Is there another option that is better?

Although i am neither prefer nor apply automatic trading , but i think all what you need to do is to use Ref() function , SetTradeDelays is just hold in abeyance the generated signal and it is designed for BackTest , so to postpone the signal and emulate the same process with arrays, you need to use Ref() function.
The above is already explained in the instruction page of SetTradeDelay() ,

Also you may consider re-looking the below line again

Buy = Buy AND BuyPrice > Low;

I think it should be rather

Buy = BuySignal AND BuyPrice > Low;