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 Vietanhnguyen2hotmailcom, Yesterday, 10:29 AM
          4 responses
          23 views
          0 likes
          Last Post Vietanhnguyen2hotmailcom  
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          35 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          37 views
          0 likes
          Last Post ageeholdings  
          Started by reynoldsn, Today, 02:34 PM
          0 responses
          13 views
          0 likes
          Last Post reynoldsn  
          Started by nightstalker, Today, 02:05 PM
          0 responses
          21 views
          0 likes
          Last Post nightstalker  
          Working...
          X