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

Strategy doesn't work properly unless AddDataSeries() is added

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

    Strategy doesn't work properly unless AddDataSeries() is added

    Hey all,

    I'm working on a 5 minute strategy, that started off as a 1 and 5 minute multi time-series strategy. Anyways, I'm noticing something strange when I remove or comment out the line

    AddDataSeries(BarsPeriodType.Minute, 5);

    The strategy now only takes about 60-70% of the trades it took when that line was left in. From my understanding, if the strategy is designed to run on a 5 minute chart, AddDataSeries() doesn't need to be called at all. It just needs to be set to a 5 minute data series on a chart or in the Strategy Analyzer.

    Can a NinjaTrader expert take a look at my strategy code below, and do the following?

    1) Uncomment AddDataSeries(BarsPeriodType.Minute, 5);
    2) Change (starts on line 320)

    if(BarsInProgress == 1 && CurrentBar >= 3){


    if(IsSwingHigh())

    listSwingHighs.Add(Draw.Line(this, string.Format("MSS{0}", CurrentBar), false, 2, High[1], -1, High[1], Brushes.Green, DashStyleHelper.Dash, 1));

    else if(IsSwingLow())

    listSwingLows.Add(Draw.Line(this, string.Format("MSS{0}", CurrentBar), false, 2, Low[1], -1, Low[1], Brushes.Red, DashStyleHelper.Dash, 1));


    }

    to

    if(BarsInProgress == 0 && CurrentBar >= 3){

    if(IsSwingHigh())

    listSwingHighs.Add(Draw.Line(this, string.Format("MSS{0}", CurrentBar), false, 2, High[1], -1, High[1], Brushes.Green, DashStyleHelper.Dash, 1));

    else if(IsSwingLow())

    listSwingLows.Add(Draw.Line(this, string.Format("MSS{0}", CurrentBar), false, 2, Low[1], -1, Low[1], Brushes.Red, DashStyleHelper.Dash, 1));


    }

    3) Run a backtest and note how many trades are taken
    4) Then, completely remove the 5 minute data series and change all references to BarsInProgress to 0 (primary series) and BarsArray[0] to just Bars

    I am desperately trying to understand why the number of trades are different, when the entry logic is exactly the same code. The only thing is that it changes from a multi time-series strategy to a single.

    Any help would be appreciated. Thanks!

    Attached Files
    Last edited by jaybedreamin; 03-02-2023, 08:09 PM.
    jaybedreamin
    NinjaTrader Ecosystem Vendor - Zion Trading Algos

    #2
    Hello jaybedreamin,

    If by removing that the results change that means that changed how your logic was executed. Our support can't debug scripts for you so this would be a situation where you would need to add prints to see how commenting that out changes your logic. I see that you have a condition for BarsInProgress 1 so removing AddDataSeries effectively turns off that part of your logic.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,789 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    13 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    63 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X