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

Trying to find a keyword

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

    Trying to find a keyword

    As stated in the header, I am trying to locate a keyword. I am not entirely sure it exists in ninjascript, so I thought I would ask before I go through the trouble of creating a method.

    In mql4 there is a keyword "Digits", which gives the precision of the instrument in question. For instance, with my broker, the EURUSD has a current bid price of 1.37755. The "Digits" keyword would return a result of "5", since there are 5 decimal places of precision in the price. QUESTION: Is there a keyword in ninjascript that does the same thing, and if so, what is it?

    Thanks for the help!

    #2
    Hello Antny,

    NinjaTrader does not have a built in method for this no, but there is C# method that I found that may help you with this so you do not have to write a custom method for this that you may try.

    I'm wondering if there is a concise and accurate way to pull out the number of decimal places in a decimal value (as an int) that will be safe to use across different culture info? For example: 19.0


    Code:
    Print("How may decimals is the current price: "+BitConverter.GetBytes(decimal.GetBits((decimal)Close[0])[3])[2]);
    
    Print("How may decimals is the Tick Size: "+BitConverter.GetBytes(decimal.GetBits((decimal)TickSize)[3])[2]);
    JCNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JC View Post
      Hello Antny,

      NinjaTrader does not have a built in method for this no, but there is C# method that I found that may help you with this so you do not have to write a custom method for this that you may try.

      I'm wondering if there is a concise and accurate way to pull out the number of decimal places in a decimal value (as an int) that will be safe to use across different culture info? For example: 19.0


      Code:
      Print("How may decimals is the current price: "+BitConverter.GetBytes(decimal.GetBits((decimal)Close[0])[3])[2]);
      
      Print("How may decimals is the Tick Size: "+BitConverter.GetBytes(decimal.GetBits((decimal)TickSize)[3])[2]);
      That will save me a bit of time. This is the code I ended up using:

      Code:
      digits = [COLOR="Sienna"]BitConverter.GetBytes(decimal.GetBits((decimal)(double)TickSize)[3])[2];[/COLOR]
      Print("digits: "+digits.ToString()+"  TickSize: "+TickSize.ToString());
      The output is "digits: 4 TickSize: 0.0001"

      Comment


        #4
        Originally posted by Antny View Post
        That will save me a bit of time. This is the code I ended up using:

        Code:
        digits = [COLOR="Sienna"]BitConverter.GetBytes(decimal.GetBits((decimal)(double)TickSize)[3])[2];[/COLOR]
        Print("digits: "+digits.ToString()+"  TickSize: "+TickSize.ToString());
        The output is "digits: 4 TickSize: 0.0001"
        Have you seen Round2TickSize()?

        Comment


          #5
          Originally posted by sledge View Post
          Have you seen Round2TickSize()?
          No, I have not seen that one before now. My only reference is the Ninja tutorial and what I can locate on the Microsoft C# forum. Although, I seem to be picking it up reasonably well so far. I started learning NinjaScript/C# on Monday, and I have most of my indicator completed, and working properly (ticking in at 2091 lines of code as of now).

          I have had to create a few new methods, to do processes that I could not find in NinjaScript. Aside from some little things here and there, like not knowing specific keywords, and the like, the transition from mql4 (my first programming language) has been pretty smooth.

          Anyway, thanks for the tip, and when I get a chance, I will try to hunt up some info on the Round2TickSize() method.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by agclub, Yesterday, 08:57 PM
          2 responses
          16 views
          0 likes
          Last Post agclub
          by agclub
           
          Started by cre8able, 04-17-2024, 04:16 PM
          6 responses
          56 views
          0 likes
          Last Post cre8able  
          Started by Mindset, 05-06-2023, 09:03 PM
          13 responses
          293 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by kaywai, 09-01-2023, 08:44 PM
          4 responses
          600 views
          0 likes
          Last Post joselube001  
          Started by dpolyakov, 03-29-2024, 11:30 AM
          3 responses
          135 views
          2 likes
          Last Post sonia0101  
          Working...
          X