Difficulties to set the SellPrice

Hi,

For assessing the slippage I add the Spread and the "Swap" to the SellPrice.
The Swap is a penalty charged by FTMO if I hold the stock during the night.
The SellPrice works nice when I used it on Daily data, but not anymore on 1-Minute data.

The results of my backtest on QQQ are:
CAR = 10.2% without slippage
CAR = 8.2% with the swap (looks correct)
!! CAR = 6.67% with the spread (looks far too high)
!! CAR = 6.67% with the swap AND the spread (Impossible...)

I am unable to find the glitch.

Param_Spread = ParamList("The spread is","Real Spread|No Spread");
Spread = IIf (Param_Spread == "Real Spread",Volume,0); 
//I put the nominal value of the spread in the Volume array while importing the ticker. 
//There is no "Volume" for my ticker.
Swap_pct = Param("Swap in %", 0.03, 0, 0.1, 0.001); 

//I need the 1 minute data for the whole script, that's why I am not on the 1D Timeframe.
NYSE_Closing = Hour()==15 AND Minute()==59;

H1 = HHV (H,390); // 390 minutes between 9:30 and 16:00
L1 = LLV(L,390);
IBS=SafeDivide((C-L1),(H1-L1),0.5);

Buy = IBS<0.45 AND NYSE_Closing;
Sell = IBS>0.55 AND NYSE_Closing;

Day_buy = ValueWhen(Buy,DaysSince1900(),1);
Day_sell = DaysSince1900();
Number_days = Day_sell - Day_buy;

BuyPrice = Close;
SellPrice = Close -Spread -(Swap_pct*Number_days)*Close*0.01; 

Please review this post: How do I debug my formula?

Specifically, you would probably learn a lot from an Exploration that shows you the values of Spread and SellPrice. I would also store the Swap value in its own variable so that you can output that in the Exploration as well.

1 Like

After 4 hours of brainteasing and headaches:

SetOption("PriceBoundChecking", false);
1 Like

Remember that setting this option allows trades to occur outside High-Low range which is totally wrong. So you should fix your code instead of turning off price bound checking or just leave it enabled as it is by default.

Slippage can be accounted for by setting/increasing commission.

2 Likes