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 do I identify "First bar of day"

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

    How do I identify "First bar of day"

    Hi,

    Yes, I´ve been looking around but didn´t find any answere yet. I´m about to make an indicator that modulates the parabolic behaviour of daily volume data. Since there´s no FirstBarOfDay function, how do I identify the first, second, third.... bar/bars of a day/days?

    In my case I just need the sequence of 13 bars (6.5 hour/30min). I won´t need the indicator to adapt to bar duration, if that would matter.

    Thanks, Fredrik

    #2
    Hello Freen,

    Thank you for your post.

    You should be able to use Bars.FirstBarOfSession and Bars.BarsSinceSession for this.

    Your "day" is then defined by the start time in your chart properties.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks,

      1) Ok, so "Session" in FirstBarOfSession refers to "trading session" (as in a new trading day defined by the chart properties, in most cases 9.30-16.00)? I missunderstood the use of "session".

      2) Is there a function for retrieving bar duration (eg 30 min) onto a variable?

      Comment


        #4
        1) Yes, that's correct.

        2) For Indicators you can use Bars.Period.Value
        For Strategies it's BarsPeriod.Value

        These properties work in conjunction with Bars.Period.Id and BarsPeriod.Id to identify the specific bar type (range, minute, etc)
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hiding raw data of symbol

          Is there a way to hide the raw data of a symbol? I need only display the indicator of the data that is bulky and of no interest. When I´ve been looking around the forum it seems the primary (raw) data always has to be displayed.

          Hiding ALL raw symbol data would be very convenient. If I understand things right this is possible only in secondary symbols in a multi symbol indicator.

          (Looking around this forum I´m mighty impressed by the NT support team and your quick and informative resonse!!!)

          Comment


            #6
            FREEN, you could always code up your indicator into a strategy which would mean the data wouldn't have to be displayed although the calculations would still work correctly.
            AustinNinjaTrader Customer Service

            Comment


              #7
              Ok, thanks! Does that mean primary (raw) data always has to be displayed when it comes to the charts? After all that´s where (at least I) spend much time developing/tuning the indicator and strategies. Y/N?

              Comment


                #8
                Yes, that is what that means.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Input data types for indicator methods

                  Won´t the indicator methods accept a variable as input?

                  E.g:

                  if
                  (Bars.BarsSinceSession==1)
                  {
                  double BAR=(0.6*(Close[0]-Open[0]));
                  Plot0.Set(
                  BAR);
                  double SMA = SMA(BAR, PeriodSMA)[0];
                  Plot1.Set(SMA);
                  }

                  Comment


                    #10
                    Hello Freen,

                    SMA can take a DataSeries as input. The following help guide tutorial can help when working with DataSeries.


                    You can convert that double variable into a DataSeries. DataSeries are:
                    1) Declared in variables region:
                    Code:
                    private DataSeries Bar;
                    2)Instantiated in the Initialize() method:
                    Code:
                    Bar = new DataSeries (this);
                    3) Values Set in OnBarUpdate():
                    Code:
                    Bar.Set(.6 *(Close[0] - Open[0]));

                    You can then pass this into SMA:

                    Code:
                    Plot1.Set(SMA(Bar, PeriordSMA)[0]);
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Wonderful, thanks!

                      1) How come this plots:

                      if (Bars.FirstBarOfSession==true)
                      {
                      Bar.Set(
                      .37 *(Close[0] - Open[0]));
                      Plot0.Set(
                      .37 *(Close[0] - Open[0]));
                      Plot1.Set(SMA(Bar, PeriodSMA)[
                      0]);
                      }

                      but not this:

                      if (Bars.FirstBarOfSession==true)
                      {
                      Bar.Set(
                      .37 *(Close[0] - Open[0]));
                      Plot0.Set(Bar
                      );
                      Plot1.Set(SMA(Bar, PeriodSMA)[
                      0]);
                      }

                      2) What defines wich plot is on top (the plot layers)?

                      Comment


                        #12
                        1) Plot Set statements are looking for a double value. This could be index[0] for the "Bar" DataSeries.
                        Plot0.Set(Bar[0]);

                        2) When you create plots through the wizard, it adds a public property block that will determine the order.
                        Code:
                         
                        public DataSeries Plot0
                        {
                        get { return Values[0]; }
                        }
                        The number in Values[0] will increase for each plot. The order that the plots are added in the Initialize() method determines which "Values" index the plot will occupy.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_RyanM View Post
                          1) Plot Set statements are looking for a double value. This could be index[0] for the "Bar" DataSeries.
                          Plot0.Set(Bar[0]);


                          Ok, so it should be indexed like this:..

                          Bar.Set(
                          .37 *(Close[0] - Open[0]));
                          Plot0.Bar[0]);


                          ...but how come it needn´t be indexed here:

                          Set(
                          Plot1.Set(SMA(Bar, PeriodSMA)[0]);



                          Thanks again Ryan! I´ve printed the Softsteel C# manual to gain better insights in NT programming.




                          Comment


                            #14
                            Originally posted by FREEN View Post
                            ...but how come it needn´t be indexed here:

                            Think i just got that; Cos the "SMA(Bar, PeriodSMA)" method returns a double, right?!

                            Comment


                              #15
                              Yes, in that context SMA is looking for a DataSeries input.

                              The plot Set method is looking for a double input.

                              A good way of seeing what datatype a given method is looking for is with intellisene. In the NinjaScript editor type SMA(

                              It will list all the supported overloads for SMA and you can cycle through using the Up and Down arrows on your keyboard. For SMA, it can accept either a dataseries and period or just the period. When using just the period the price type is selectable when adding the indicator to the chart.
                              Last edited by NinjaTrader_RyanM1; 04-19-2010, 03:11 PM.
                              Ryan M.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sgordet, Today, 11:48 AM
                              0 responses
                              0 views
                              0 likes
                              Last Post sgordet
                              by sgordet
                               
                              Started by Trader146, Today, 11:41 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Trader146  
                              Started by jpapa, 04-23-2024, 07:22 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post rene69851  
                              Started by funk10101, Today, 11:35 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post funk10101  
                              Started by samish18, Today, 11:26 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post samish18  
                              Working...
                              X