It is not forward looking to do something like in following example:
SetTradeDelays( 0, 0, 0, 0 );
myma = MA( Close, 20 );
BuyPrice = Close;
Buy = Cross( Close, myma );
Signal occurs at Close of bar and close of bar is used as trade price. Both are present at same time.
But it is just unrealistic/unlikely that you would get trade entry/exit at close of bar in realtime.
So a more realistic approach in backtesting is doing this -> adding a bar entry delay and entering next bar at open price of bar:
SetTradeDelays( 1, 1, 1, 1 );
myma = MA( Close, 20 );
BuyPrice = Open;
Buy = Cross( Close, myma );
BTW, MA( Close, 20 ) price is known at close of bar only.
On the other hand a future leak would be this example:
SetTradeDelays( 0, 0, 0, 0 );
myma = MA( Close, 20 );
BuyPrice = Open;
Buy = Cross( Close, myma );
Trade price at open but a signal occurring at close of same bar (since there isn't any bar delay there).
As for adding bar delays.... either by using backtester function SetTradeDelays or by using Ref() function.
Using SetTradeDelays:
SetTradeDelays( 1, 1, 1, 1 );// one bar delay for all entries and exits
myma = MA( Close, 20 );
BuyPrice = Open;
Buy = Cross( Close, myma );
Using Ref():
SetTradeDelays( 0, 0, 0, 0 );// overriding analysis settings' delays of trades tab ensuring it is zero
myma = MA( Close, 20 );
BuyPrice = Open;
Buy = Ref(Cross( Close, myma ), -1);// one bar entry delay
Both upper two examples do the same thing.