Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 AlessioCianini12, Today, 01:55 PM
    0 responses
    2 views
    0 likes
    Last Post AlessioCianini12  
    Started by rajneesh.sehgal, Today, 12:06 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by mo_fi, 01-21-2021, 10:08 PM
    22 responses
    1,313 views
    0 likes
    Last Post Wessel
    by Wessel
     
    Started by ezrollin, 01-12-2022, 03:43 PM
    2 responses
    39 views
    0 likes
    Last Post iq200
    by iq200
     
    Started by Red_70, Today, 11:07 AM
    3 responses
    16 views
    0 likes
    Last Post Red_70
    by Red_70
     
    Working...
    X