Using previous bar for buy, timing question

I am having an issue where the back test shows positions entered 1 day prior that were not included on the 1 day priors explore. I know that many things could cause this but I am trying to isolate. I am wondering if it has to do with a problem in my use of Ref(. . . , -1)

If I am using the prior bar for my buy signal, should all the other buy signal variables such as position score and entry and any filters also be set to Ref( . . . , -1) or the current bar?

Here is an example of this code. Can assume no current held positions, no relevant position # limits. The question is should positionscore and ROCfilter be referenced to 1 bar earlier because buy is referenced to 1 bar earlier?

Thanks in advance!

Positionscore = 1/RSI(15); 
ROCfilter = ROC(Close, 40); > 0.10; 
Entry = RSI(15) <10 AND ROCfilter; 

Buy = Ref(Entry, -1); 
SetTradeDelays(0,0,0,0); 

If setting trade delay to zero then you have to take care of delays.

SetTradeDelays(0,0,0,0);

Positionscore = 1/Ref(RSI(15), -1); 
ROCfilter = ROC(Close, 40) > 0.10; 
Entry = RSI(15) <10 AND ROCfilter; 

Buy = Ref(Entry, -1); 
Buyprice = Open;

1 Like