Trade delays help needed

Dear Experts,

I am backtesting a RSI based strategy & my Buy/Sell/Short/Cover conditions are as follows -

Buy when RSI(14) closed above 60
Sell when RSI(14) closes below 60
Short when RSI(14) closes below 40
Cover when RSI(14) closed above 40

I am doing this backtest on EOD data & I plan to take trade next day based on the scan today. I have a couple of questions -

  1. What trade delays should I set under Trades tab?
  2. If I set Sell & Cover at Open with 0 day delays to square off my positions, does it sound logical since its on EOD?

Here is the code for your review -

RSI1=RSI(14);
Buy = Cross(RSI1, 60);
Sell = Cross(60, RSI1);
Cover = Cross(RSI1, 40);
Short = Cross(40, RSI1);

Thanks in advance
Vihaan

  1. You should set delay > 0
  2. No. If you trade prices to Open with zero delay then it would be looking ahead bias... since your signals are at close.

BTW, alternativally to TradeTab options you may use SetTradeDelays function. That function overrides UI settings (but trade prices are not overridden for every case).

trade_delay = 1;
SetTradeDelays( trade_delay, trade_delay, trade_delay, trade_delay);

BuyPrice = SellPrice = ShortPrice = CoverPrice = Open;

RSI1=RSI(14);
Buy = Cross(RSI1, 60);
Sell = Cross(60, RSI1);
Cover = Cross(RSI1, 40);
Short = Cross(40, RSI1);

Note: SetTradeDelays is backtester function. Alternativally you may use Ref() function.

trade_delay = 1;

BuyPrice = SellPrice = ShortPrice = CoverPrice = Open;

RSI1=RSI(14);

Buy = Cross(RSI1, 60);
Sell = Cross(60, RSI1);
Cover = Cross(RSI1, 40);
Short = Cross(40, RSI1);

Buy = Ref(Buy, -trade_delay);
Sell = Ref(Sell, -trade_delay);
Cover = Ref(Cover, -trade_delay);
Short = Ref(Short, -trade_delay);
2 Likes

Thank you so very much @fxshrat for your quick and detailed response. Much appreciated. This is exactly what I was looking for and you explained it in very simple manner.

One more question - Based on your experience, what would be the recommended settings for EOD analysis? I understand 1 day delay is needed since it is EOD but should I build my system based on Open or Close prices? Do you have any recommendations on how to increase the effectiveness of these settings?

Thanks again in advance.

@amibrofan,

Signals occuring at Close of bar and trade prices
at close of bar are both present at same time.

But it is unrealistic/unlikely that you would get trade entry/exit at close of bar in __realtime__.

So using trade prices at next bar's open is more realistic approach.

2 Likes

Thank you so very much fxshrat for your response. This really helps. I have set the delays of 1,1,1,1 at Open for all 4 type of trades and now the results are good. Earlier I was using 0,0 for Sell and Cover @ Open which was giving incorrect results. I appreciate your help. God bless you mate!