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

logic behind multiple instrument processing

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

    logic behind multiple instrument processing

    Dear NT experts,

    I would like to know the logic for processing multiple isntruments. Here is an example copied from online guide. It says when OnBarUpdate is processing the primary instrument, then do calculations on primary isntrument 0, and second instrument BarsArray[1], plus third isntrument BarsArray[2]. I am not certain what is actually processed. Because the condition is "if (BarsInProgress == 0)", I would assume BarsArray[2] is not availble when this condition is true. How BarsArray[2] can be accessed? Can you shed some light?

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 0)
    {
    if (CCI(20)[0] > 200 && CCI(BarsArray[1], 20)[0] > 200
    && CCI(BarsArray[2], 20)[0] > 200)

    {
    // Do something
    } }
    }

    #2
    binwang2,

    BarsArray[2] may not be available on the very first bar, but it will be available once data was received in BarsInProgress 2 at some point in time. From that point forward it will reference the latest known BarsArray[2] value for your indicator.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Josh.

      Can i assume BarsArray[2] data will also be availble some point of time forward even with this
      "if (BarsInProgress != 0)
      return;


      "
      at the very begining of OnBarUpdate()?

      Comment


        #4
        Sure. It is available once data was received in BarsInProgress == 2. Where ever you access BarsArray[2] will give you the recent value of the indicator at that moment in time. If there are queued events for further updating BarsArray[2]'s value, this will not be shown to you unless you call the indicator again later.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jclose, Today, 09:37 PM
        0 responses
        5 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,413 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Today, 08:53 PM
        0 responses
        11 views
        0 likes
        Last Post firefoxforum12  
        Started by stafe, Today, 08:34 PM
        0 responses
        11 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by sastrades, 01-31-2024, 10:19 PM
        11 responses
        169 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X