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

multiple data series bar update ?

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

    multiple data series bar update ?

    so i have an indicator with multiple data series, i have the chart data series, and I add in 2 larger candle data series in the indicator.

    I am trying to write code on the bar update that will only be hit when the larger, indicator added bars close, not the smaller candle from the chart. Is there any way to do this?

    #2
    Hello ErikY,

    Thank you for your reply.

    Yes, you can check the BarsInProgress value of the series that is currently iterating through OnBarUpdate and only execute code if it is currently on a specific series.

    For example, if we have a primary data series of one minute, and we add two secondary series, a 5 and a 15 minute like below:

    Code:
    AddDataSeries(BarsPeriodType.Minute, 5);
    AddDataSeries(BarsPeriodType.Minute, 15);
    The primary 1 minute series will have a BarsInProgress of 0, the first added data series (5 minute) will have a BarsInProgress value of 1, and the second added data series will have a BarsInProgress value of 2. So, within OnBarUpdate we can use those to specify when to execute certain code:

    Code:
    //within OnBarUpdate
    
    if (BarsInProgress == 0)
    {
    // code in here will only be executed when the 1 minute series is processing in OnBarUpdate
    }
    else if (BarsInProgress == 1)
    {
    // code in here will only be executed when the 5 minute series is processing
    }
    else if (BarsInProgress == 2)
    {
    // code in here will only be executed when the 15 minute series is processing
    }
    Please see this example from our help guide of a strategy that implements this kind of logic to enter on one series and exit on another:



    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      awesome, thanks much!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by sidlercom80, 10-28-2023, 08:49 AM
      172 responses
      2,277 views
      0 likes
      Last Post sidlercom80  
      Started by Irukandji, Yesterday, 02:53 AM
      2 responses
      17 views
      0 likes
      Last Post Irukandji  
      Started by adeelshahzad, Today, 03:54 AM
      0 responses
      3 views
      0 likes
      Last Post adeelshahzad  
      Started by CortexZenUSA, Today, 12:53 AM
      0 responses
      3 views
      0 likes
      Last Post CortexZenUSA  
      Started by CortexZenUSA, Today, 12:46 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Working...
      X