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 TAJTrades, Today, 09:46 AM
    0 responses
    1 view
    0 likes
    Last Post TAJTrades  
    Started by rhyminkevin, Yesterday, 04:58 PM
    5 responses
    62 views
    0 likes
    Last Post dp8282
    by dp8282
     
    Started by realblubb, Today, 09:28 AM
    0 responses
    4 views
    0 likes
    Last Post realblubb  
    Started by AaronKoRn, Yesterday, 09:49 PM
    1 response
    19 views
    0 likes
    Last Post Rikazkhan007  
    Started by ageeholdings, Today, 07:43 AM
    0 responses
    12 views
    0 likes
    Last Post ageeholdings  
    Working...
    X