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

Daily Data Series not getting run in OnBarUpdate while backtesting

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

    Daily Data Series not getting run in OnBarUpdate while backtesting

    Hello, I am trying to run a strategy that runs a one minute data series and a one day data series. I have the Calculate property set to OnBarClose. The one minute data series gets run in OnBarUpdate normally, but the one day data series never gets run in OnBarUpdate(I am back testing multiple days).

    Currently the one minute data series is the primary data series. I have tried making the one day data series the primary data series and the one minute the secondary data series. I got the same result.

    I also ensured that the historical data downloaded was both minute and day, and I ensured that the data type was 'last'.

    Here is my OnStateChanged method:

    Code:
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "T2V1S1V1FU";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 4;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    BarsRequiredToTrade = 0;
    //AddChartIndicator(RSI(RSIPeriod, RSISmooth));
    AddDataSeries("MGC 04-22", BarsPeriodType.Day, 1, MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
    
    }
    }
    Any help would be appreciated!

    Thanks,

    -Parker

    #2
    Hello plwieseler,

    From the given code I don't see what may be the problem. Have you tried adding a Print to OnBarUpdate like the following:

    Code:
    Print(Time[0] + " BarsInProgress: " + BarsInProgress);
    Alternatively are you able to run a script on a daily series for this instrument?

    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for the response! After looking through the output window I realized I made a stupid mistake...I had created a trading hours filter at the top of OnBarUpdate, and I was running the logic for the daily data series after that filter, so it never got hit because the daily bar closed at the start of the day.

      Thanks,

      -Parker

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      603 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      22 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      21 views
      0 likes
      Last Post Pattontje  
      Started by flybuzz, 04-21-2024, 04:07 PM
      17 responses
      230 views
      0 likes
      Last Post TradingLoss  
      Working...
      X