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

    #16
    Hello imalil,

    Can you please specify the types of your four variables (ats, askVol, bidVol, tickValue)?

    In the case that they are all ints, your result will be an int. Here is an example:
    Code:
    int answer = 0;
    int firstNumber = 33;
    int secondNumber = 42;
    int thirdNumber = 12;
    
    answer = (firstNumber + secondNumber) / (thirdNumber);
    Print(answer.ToString()); // will print out 6
    Please take a look at this MSDN link: https://msdn.microsoft.com/en-us/library/3b1ff23f.aspx

    "When you divide two integers, the result is always an integer. For example, the result of 7 / 3 is 2."

    Is your ats variable a double? What happens when you cast askVol, bidVol, and tickValue as doubles?

    Example:
    Code:
    double answer = 0;
    int firstNumber = 33;
    int secondNumber = 42;
    int thirdNumber = 12;
    
    answer = (double)(firstNumber + secondNumber) / (double)(thirdNumber);
    Print(answer.ToString()); // will print out 6.25, the correct answer
    More information about division and casting can be found here: http://www.dotnetperls.com/divide
    Zachary G.NinjaTrader Customer Service

    Comment


      #17
      That's the kind of info I need. ats is double, advol, bidvol is private long, tickValue is int. If I change tickValue and askvol, bidvol to doubles you think it might solve the problem?

      Comment


        #18
        Hello imalil,

        It would be up to you if you would like to change them to doubles.

        Alternatively, you can cast them as doubles in your calculation.

        Example:
        Code:
        ats = (double)(askVol + bidVol) / (double)(tickValue);
        Zachary G.NinjaTrader Customer Service

        Comment


          #19
          Yes, I realized that right after I sent the post.

          Thanks again, this solves my problem.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,227 views
          0 likes
          Last Post xiinteractive  
          Started by andrewtrades, Today, 04:57 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          7 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          440 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          12 views
          0 likes
          Last Post FAQtrader  
          Working...
          X