Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access book from different bars in progress issue

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

    Access book from different bars in progress issue

    Hi I have multi strategy.
    in my primary bars in progress I reference book from another bars in progress and it’s not recognising.
    is there a trick to reference Bools in another barsinpeofress?

    #2
    Hello tkaboris,

    Thanks for your post.

    You should create the bool as a class level variable in your script.

    Once the bool is created as a class-level variable, you could set the bool in say BarsInProgress 1 and then reference the bool in a different BarsInProgress in your script.

    See this help guide page for details about working with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm

    The Strategy Builder could be used to create a bool variable and then you could click the 'View code' button to see the generated syntax to create that bool in your script.

    Strategy Builder Inputs and Variables screen: https://ninjatrader.com/support/help...er_screens.htm

    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      HI
      So i have this issue with bools.
      private bool 1buy;
      private bool 2buy;


      primary series {
      if (Close[1] > Open[1]){
      bool 1buy
      }

      if(1buy && 2buy)
      enter long
      }


      secondary series {
      if (Close[1] > Open[1])
      bool 2buy
      }

      The problem is that 2buy reads from the primary series and not from secondary. when i print 2buy from secondary series it prints fine, but whenn i print 2buy in primary series its not picking up correctly

      How can i work this out?


      Comment


        #4
        I have implemented T series
        private Series<bool> mySecondaryDoubleSeries;
        in dataloaded
        mySecondaryDoubleSeries = new Series<bool>(BarsArray[2]);
        when i print it from primary series it always evaluates to false even thought it should be true
        Print("secondary series bool " + mySecondaryDoubleSeries[0]);

        Comment


          #5
          Am I doing it right?

          Comment


            #6
            Hello tkaboris,

            This would only be true during BarsInProgress 0 if the value was set to true during the most recent bar update of BarsInProgress 0.

            If you are synchronizing a custom series to an added data series, this will have a slot for every bar of the added series, not the primary series.

            This means from the primary series, you would be referencing the most recently updated bar of the added series.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              yes thats what i need, i need to access last condition on secondary series from primary.
              So do i need T series for that? or no?

              Comment


                #8
                Hello tkaboris,

                Thanks for your notes.

                A custom Series<bool> could be used to check if BarsInProgress == 1 and set the Series<bool> to true or false.

                You could then access the Series<bool> variable value in BarsInProgress 0. To understand how the script is behaving, prints should be added to the script that prints out the value of the custom Series<bool> variables in BarsInProgress 0 along with the Time. Prints should also be added in BarsInProgress 1 that prints out the Series<bool> value along with the Time. The prints could then be reviewed in the NinjaScript Output window to see how they are behaving.

                Below is a link to a forum post that demonstrates how to use prints to understand behavior.
                https://ninjatrader.com/support/foru...121#post791121

                Working with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nts.htm​
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                66 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                141 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                76 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                47 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                51 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X