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

Add() Bars where PeriodType.Minute is synchronized with Primary Bars

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

    Add() Bars where PeriodType.Minute is synchronized with Primary Bars

    Hello,

    I am attempting to Add() another series of data to my indicator, and would like the new series to be "synchronized" with the Primary, such that if the Primary is 1min, the series is 1min. If the chart changes to 3min, the new series also is 3min.

    On the chart already: SPY 1min (Primary Bars)

    In initialize:
    Add("AAPL", PeriodType.Minute, 1);


    I'd like it to work something like this...

    Add("AAPL", BarsArray[0].BarsType, BarsArray[0].BarsType.Period);

    ..but can't seem to get it to work.

    #2
    Hello ntfred,

    Thank you for your post.

    There is no supported method to pull the primary series period type and period to apply to any additional series you add to the code.

    Please let me know if I may be of further assistance.

    Comment


      #3
      Wow, fast reply. Thank you!

      Does "no supported method" mean "impossible" or "I'll have to figure it out on my own"?

      Just wondering... would rather not spend a bunch of time trying to figure out something that is impossible.

      Comment


        #4
        Hello ntfred,

        Thank you for your response.

        Nothing is impossible, however the methods to achieve this are unsupported.

        There have been mixed results using BarsPeriod.Id and BarPeriod.Value from my understanding, yet this is advised not to be accessed in the Initialize() method. For information on BarsPeriod please visit the following link: http://www.ninjatrader.com/support/h...barsperiod.htm

        Please let me know if I may be of further assistance.

        Comment


          #5
          Perfect, thank you.

          Comment


            #6
            How to distinguish between primary and secondary bars

            Hi

            I am working on an indicator that is working with Primary Bars of 10 min and Secondary Bars of 1 second. This indicator is being called from a Strategy.

            However, when I have the following code:

            Code:
            if (BarsInProgress == 1)
            {
               Print(...);
            }
            else if (BarsInProgress == 0)
            {
              Print(...);
            }
            I noticed that a bar is being considered simultaneously primary and secondary bar. For instance, the bar that occurs at 18:20:00 is being printed twice with the code above.
            How can I distinguish between them?

            Thanks

            Comment


              #7
              Originally posted by danieladacruz View Post
              Hi

              I am working on an indicator that is working with Primary Bars of 10 min and Secondary Bars of 1 second. This indicator is being called from a Strategy.

              However, when I have the following code:

              Code:
              if (BarsInProgress == 1)
              {
                 Print(...);
              }
              else if (BarsInProgress == 0)
              {
                Print(...);
              }
              I noticed that a bar is being considered simultaneously primary and secondary bar. For instance, the bar that occurs at 18:20:00 is being printed twice with the code above.
              How can I distinguish between them?

              Thanks
              Make the BarsInProgress part of the Print() arguments?

              Comment


                #8
                Originally posted by koganam View Post
                Make the BarsInProgress part of the Print() arguments?
                But the Print is only a way to see what is happening. Because I want to do different things depending wheter is primary or secondary data...

                Comment


                  #9
                  That's exactly what the BarsInProgress will give you as feedback, if the OnBarUpdate() is called from your primary series or secondary series. koganam's idea was to include so you could differentiate the print outcomes between the series calls.
                  BertrandNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by funk10101, Today, 08:14 AM
                  3 responses
                  4 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by frankthearm, Today, 09:08 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post frankthearm  
                  Started by samish18, Yesterday, 08:57 AM
                  11 responses
                  28 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by yertle, Today, 08:38 AM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by love2code2trade, Yesterday, 01:45 PM
                  3 responses
                  22 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X