similar effect you get if you use settradedelays(1,1,1,1). I am used to Ref(Buy,-1) and I leave setttradedelays(0,0,0,0) because I can directly put this signal in the chart and shows me where it is at. There is nothing mysterious about it. It just shifts signals 1 bar forward. Yesterdays signal will be executed on todays bar. Ofcourse you will get a different result in the backtest because your signals are delayed by 1 bar. You can choose not to use it but then you will have to use settradedelays(1,1,1,1). If implemented properly this should give the same result. You need to use one or the other because when you use the close price to define your signal you will only be able to enter at the open of the next bar.
Ed Does that mean that the Portfolio backtester passes up the stock if there is no room to purchase. Conversly if you remove Ref(Buy,-1), is the stock purchased when the portfolio allows this. Ref(Buy,-1) seems to impact the performance of the portfolio backtest. To tell you the truth this is the 1st piece of code I've seen this used.
