Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Slippage with Intrabar Granularity?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Slippage with Intrabar Granularity?

    Hi,

    I'm trying to add slippage to my backtests but struggling and hoping for some help please. I'm running Strategy Analyzer on an instrument list (50 stocks). My primary data series is 1min bars. I've added a secondary dataseries for tick data:

    Code:
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Tick, 1);
    }
    The strategy calculates on the primary 1min but then sends the orders to process on the secondary (tick) dataseries:

    Code:
    EnterLong(barsInProgressIndex:1, quantity:convertedBaseOrderQty, signalName:"BuyLong");
    My SetDefaults settings are:

    Code:
    if (State == State.SetDefaults)
    {
    Description = @"MVSR Strategy";
    Name = "MVSR";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.High; //tried Standard & High
    Slippage = 50; //tried various settings.
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    Within the Strategy Analyzer UI itself, I can't select high (it brings up the error "high order fill resolution is only available for single-series strategies. for multi-series strategies, please program directly into your strategy the more granular resolution you would like to simulate order fills with") so standard is the only option to proceed with. I've tried setting the Slippage at various levels (5, 10, 50) in both the code and the UI, but the PNL output of the Strategy Analyzer remains unchanged (total net profit, gross profit, gross loss, all unchanged).

    FYI: My live strategies results have large differences to my backtests (I'm familiar with the reasons for this, such as https://ninjatrader.com/support/help...ime_vs_bac.htm) and I think it's due to a slippage/time delay. E.g. for one particular stock, the backtest shows a $14.47 long entry at 1:03:05PM and a $14.55 exit at 1:38:08PM. In Real-Time I filled at $14.48 at 1:03:05PM (1cent off) and exited at $14.53 at 1:38:08PM (2cents off). Looking at the tick data the slippage was 3-5 ticks on entry, and upto 13 ticks on exit. I need to factor in some form of slippage/time delay into my backtests to help them be more realistic but struggling to add.

    Many thanks in advance

    ChainsawDR

    #2
    Hello ChainsawDR,

    You are correct, high order fill resolution cannot be used when multiple series are added to the script.

    Unfortunately, no, slippage does not apply with 1-tick intra-bar granularity.

    With 1-tick intra-bar granularity the size of the bar is 1 tick. The slippage applied will only be between the high and low (the prices reach while the bar was open). If the high and low are the same, slippage cannot be applied.

    It may be necessary to test the script with Playback instead.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    44 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    65 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X