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

Knowing the primary dataseries time

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

    Knowing the primary dataseries time

    Good morning

    How could i know the primary dataseries time (type and value)?

    Thank you.

    #2
    Good morning - you could check with BarsPeriod Id and Value - http://www.ninjatrader.com/support/h...barsperiod.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand.

      I Print() in my code:

      Code:
      protected override void Initialize(){
            Print("Type: "+BarsPeriod.BasePeriodType);
            Print("Value: "+BarsPeriod.BasePeriodValue);
      .
      .
      .
      
      protected override void OnBarUpdate(){
            Print("Type: "+BarsPeriod.BasePeriodType);
            Print("Value: "+BarsPeriod.BasePeriodValue);
      .
      .
      .
      .
      But despite i change the Value and Type of my chart the output is always :

      Type: Minute
      Value: 1



      What am I doing wrong?

      Comment


        #4
        Please access / print it only from outside Initialize(), so for example in your OnBarUpdate().

        Also: Can you please try refreshing then your NinjaScript calcs via F5?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Yes Bertrand, i tried but same result.

          I update the chart with F5 and i tried removing indicator and creating again, but same result.

          (No errors in log tab)

          Thanks

          Comment


            #6
            Originally posted by marynja View Post
            Thanks Bertrand.

            I Print() in my code:

            Code:
            protected override void Initialize(){
                  Print("Type: "+BarsPeriod.BasePeriodType);
                  Print("Value: "+BarsPeriod.BasePeriodValue);
            .
            .
            .
            
            protected override void OnBarUpdate(){
                  Print("Type: "+BarsPeriod.BasePeriodType);
                  Print("Value: "+BarsPeriod.BasePeriodValue);
            .
            .
            .
            .
            But despite i change the Value and Type of my chart the output is always :

            Type: Minute
            Value: 1



            What am I doing wrong?
            What kind of bars are you using? Kagi, LineBreak, PointAndFigure, or Renko Bars?

            Comment


              #7
              Thank you koganam.

              Was my error, i used simple Add() method.

              Any suggestions for another best method?
              Thank you.

              Comment


                #8
                Originally posted by marynja View Post
                Thank you koganam.

                Was my error, i used simple Add() method.

                Any suggestions for another best method?
                Thank you.
                Your question asked about the "primary bars". The "Add" function has no relationship to the primary bars.
                Last edited by koganam; 12-14-2011, 11:31 AM. Reason: Corrected spelling

                Comment


                  #9
                  please delete
                  Last edited by marynja; 12-14-2011, 10:53 AM.

                  Comment


                    #10
                    Thank you koganam.

                    I am confused. Wait, i am going to explain my intention.

                    I want to call an external indicator in a given time, then i using this:

                    Code:
                    private int chartTime=15;
                    
                    Add(PeriodType.Minute, chartTime);
                    
                    MyIndicator(BarsArray[1],chartTime);
                    But i want to know the primary time for initialice with it. I wait explained properly.

                    I want if its the first time the indicator is loaded, the secundary time will be the same as primary time.The im trying with next code:

                    Code:
                    private int chartTime=15;
                    
                    [B]if(BarsPeriod.BasePeriodType.ToString()=="Minute"){chartTime=BarsPeriod.BasePeriodValue;}[/B]
                    
                    Add(PeriodType.Minute, chartTime);
                    
                    MyIndicator(BarsArray[1],chartTime);
                    
                    
                    // Too i declare a public ChartTime var
                            [XmlIgnore()]
                            [GridCategory("Parameters")]
                            public int ChartTime
                            {
                                get { return chartTime; }
                                set { chartTime= value; }
                            }
                    Last edited by marynja; 12-14-2011, 09:10 AM.

                    Comment


                      #11
                      marynja, unfortunately we could not support the dynamic Add() ing of series - we would suggest you hardcode the series / interval needed in or another way is to offer a user input here.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by marynja View Post
                        Thank you koganam.

                        I am confused. Wait, i am going to explain my intention.

                        I want to call an external indicator in a given time, then i using this:

                        Code:
                        private int chartTime=15;
                        
                        Add(PeriodType.Minute, chartTime);
                        
                        MyIndicator(BarsArray[1],chartTime);
                        But i want to know the primary time for initialice with it. I wait explained properly.

                        I want if its the first time the indicator is loaded, the secundary time will be the same as primary time.The im trying with next code:

                        Code:
                        private int chartTime=15;
                        
                        [B]if(BarsPeriod.BasePeriodType.ToString()=="Minute"){chartTime=BarsPeriod.BasePeriodValue;}[/B]
                        
                        Add(PeriodType.Minute, chartTime);
                        
                        MyIndicator(BarsArray[1],chartTime);
                        
                        
                        // Too i declare a public ChartTime var
                                [XmlIgnore()]
                                [GridCategory("Parameters")]
                                public int ChartTime
                                {
                                    get { return chartTime; }
                                    set { chartTime= value; }
                                }
                        So then, you are running this on just ordinary candlestick/bar charts?

                        Comment


                          #13
                          Ok Bertrand, thank you

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by cre8able, 02-11-2023, 05:43 PM
                          3 responses
                          236 views
                          0 likes
                          Last Post rhubear
                          by rhubear
                           
                          Started by frslvr, 04-11-2024, 07:26 AM
                          8 responses
                          113 views
                          1 like
                          Last Post NinjaTrader_BrandonH  
                          Started by stafe, 04-15-2024, 08:34 PM
                          10 responses
                          46 views
                          0 likes
                          Last Post stafe
                          by stafe
                           
                          Started by rocketman7, Today, 09:41 AM
                          3 responses
                          11 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by traderqz, Today, 09:44 AM
                          2 responses
                          10 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Working...
                          X