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

TickSize and TickCount

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

    TickSize and TickCount

    Hello-

    Does TickSize work in OnMarketData? I'm attempting to use it instead of the hard-coded price increment, but my system freezes when I run it.

    Also, TickCount returns a value of "1" for every bar. I'm looking for something that will count the actual ticks in a tick bar. For example, a 200 tick bar chart should return 200 every time a bar closes, not "1".

    Thank you. for the help.

    #2
    Hello imalil,

    Thank you for your inquiry.

    It is possible to utilize TickSize in the OnMarketData() method. Can you please provide sample code that duplicates the freezing behavior you are experience so I may test it on my end?

    When utilizing TickCount, you would need to ensure that CalculateOnBarClose is set to false in Initialize().

    Further information about this can be found on this topic of our support forum: http://ninjatrader.com/support/forum...ad.php?t=49902
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks. Since TickSize should work in OnMarketData I'll run some more tests.

      Regarding TickCount, I guess this means I can't incorporate it into my indicator that has bar close set to true? This is what I'm looking for.

      Thank you.

      Comment


        #4
        Hello imalil,

        TickCount is a real-time property, so CalculateOnBarClose would need to be set to false so this may function over real-time data to provide the tick count for the bar.

        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Thanks again. I'm looking to perform a calculation using the total tick count of the bar. The result will be one of my variables. I then want to use this variable in an "IF" statement in my indicator. Since tick bar charts will always give the same answer--each bar has the same number of ticks as every other bar--is there another function I can use that I'm overlooking?

          Thank you.

          Comment


            #6
            Note: This question is intended for Ninjatrader staff..

            In NT8 tick replay, for a dataseries other than 1 tick, does tick count work for historical data?
            Last edited by Ricam; 11-12-2015, 12:45 AM.

            Comment


              #7
              I don't know, I use NT7. I have not done any replaying. I have a 3rd party indicator with locked code that performs a calculation similar to what I'm trying to do. And calc on bar close is true. The only way this indicator can get the result it gets is by using the number of ticks in a bar, so I know this is possible. If I have a tick bar chart of 200, for example, the tick count should be 200 every time. I just need that tick number in a function, like tick size, so it will work on any size tick chart.

              Thanks.

              Comment


                #8
                Hello imalil,

                What you could do in your script is check BarsPeriod.Id and BarsPeriod.Value: https://ninjatrader.com/support/help...barsperiod.htm

                With these two, you can check if you are currently on a tick-based chart and then assign the value of the tick chart to a variable.

                Here's an example:
                Code:
                private int tickValue = 0;
                
                protected override void OnBarUpdate()
                {
                     if (BarsPeriod.Id == PeriodType.Tick)
                          tickValue = BarsPeriod.Value;
                }
                Originally posted by Ricam View Post
                Note: This question is intended for Ninjatrader staff..

                In NT8 tick replay, for a dataseries other than 1 tick, does tick count work for historical data?
                Hello Ricam,

                In order for TickCount to function as expected on historical data when a script is applied to a chart in NinjaTrader 8, the script's Calculate setting must be set to "On Each Tick," and Tick Replay must be enabled: http://ninjatrader.com/support/helpG...?tickcount.htm
                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  BarsPeriod.Id and BarsPeriod.Value worked, thanks for that.

                  One other very silly question: I'm printing a number on a chart but I can only get it to print an integer. I need to print a decimal to the tenths place, e.g. 1.4, no longer. I can't locate the command to do this.

                  I'm presently doing this: Print("ats: " + ats.ToString())

                  What's the correct way?
                  Thank you.

                  Comment


                    #10
                    Hello imalil,

                    If you would like to print your decimal value with only one decimal place, you can do this:

                    Code:
                    Print(String.Format("{0:0.0}", ats));
                    More about this can be found on this Stack Overflow question page: http://stackoverflow.com/questions/1...-decimal-place

                    Please, let us know if we may be of further assistance.
                    Zachary G.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you for the info. I'm sure I wasn't clear with my question so I'll clarify. The problem I'm having is I need the actual value to print. The code you gave me simply puts a .0 on the end, 1.0, 5.0, etc. For example, I have this:

                      if ((ats) > 1.1)
                      Print(String.Format("{0:0.0}", ats));

                      I need the actual value of 1.2, 1.3 and up to be seen and printed, not 2.0, 3.0, 4.0, etc.

                      I hope this clears it up.
                      Thank you.

                      Comment


                        #12
                        Hello imalil,

                        Can you please provide a sample script that duplicates this behavior that you are seeing so I can test on my end?

                        When utilizing the syntax I've provided with this sample I've created:
                        Code:
                        private double doubleTest = 21.229999999;
                        private decimal decimalTest = 33.2999999999999M;
                        
                        protected override void OnBarUpdate()
                        {
                             Print(String.Format("{0:0.0}", decimalTest));
                             Print(String.Format("{0:0.0}", doubleTest));
                        }
                        The values of 21.2 and 33.3 are printed out respectively.
                        Zachary G.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks for the reply, Zachary. I see the test you sent and I'm sure it will work, but it doesn't appear to address the underlying issue I'm having. Regarding this example:

                          if ((ats) > 1.1)
                          Print(String.Format("{0:0.0}", ats));

                          I need the increment of increase to be tenths, not whole numbers. I need the IF statement to check for any number bigger than 1.1 by tenths, eg: .1, not 1. As of now it jumps to 2.0, then 3.0, etc.

                          I would then like to print this value, to the tenths place only, on a chart.

                          So I need either the print statement or the formula or both to be adjusted.

                          I'm trying to be as clear as possible. I hope this helps.

                          Thank you.

                          Comment


                            #14
                            Hello imali,

                            Unfortunately, I am still unclear.

                            Can you please provide a sample script that duplicates this behavior? What type of variable is ats? When printing ats.ToString(), what value are you getting? What value should ats be?
                            Zachary G.NinjaTrader Customer Service

                            Comment


                              #15
                              It's a very simple calculation:

                              ats = (askVol + bidVol) / (tickValue);

                              When I Print ats.ToString() I get an integer. I want the result rounded to the tenth place: 1.5, 4.3, etc., like you'd get on a calculator rounded to the tenth place.

                              I then want to use this rounded number in an IF statement that will check for any number bigger by tenths, eg: .1, not 1. So if I want it > 1.1, then 1.2 should satisfy my statement. Right now 1.2 to 1.9 does not satisfy; but 2.0 does.

                              Thanks.

                              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
                              5 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