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

How to find out what instrument triggers the OnBarUpdate event

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

    How to find out what instrument triggers the OnBarUpdate event

    Hi,

    I'm adding 2 data series with the AddDataSeries method. The first one has hour bars. The second one has minutes bars.

    I understand the OnBarUpdate event is triggered on each bar completion of each data series (Please tell me if I'm wrong). I calculate that this event is triggered 121 times in my case since the instrument that I select in the UI has minute bars.

    I am wondering how to test if the OnBarUpdate event is triggered by the UI selected instrument (and not by the additional time series)

    Thanks

    #2
    You can use Instrument.MasterInstrument.Name to identify the instrument. Add it to an if statement, or print statement

    Print("Instrument: " + Instrument.MasterInstrument.Name);

    You can also use BarsPeriodType and BarsPeriod.Value to identify the period and period type. Use the Help on these for further info.

    Ian
    Last edited by IanC28; 01-13-2019, 02:55 PM.

    Comment


      #3
      Hello Vincere,

      OnBarUpdate will trigger for each bar for all series added to the script. The BarsInProgress value will be the index of the bar series that is currently being processed in OnBarUpdate.



      Ian is correct in that you can print the Instrument (I would suggest Instrument.FullName).


      The primary series (BarsInProgress 0) will always be the data series on the chart, or selected in the Data Series properties when adding a script to the Strategies tab of the Control Center or when backtesting.
      OnBarUpdate doesn't begin processing until all series have data.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thanks for the quick response.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Today, 06:40 PM
        0 responses
        9 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        7 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        7 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        168 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X