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

Strange values

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

    Strange values

    Hi,

    FGBL has tick of 0.01. Now, when I backtested a strategy, High[0] - Low[0] equals to 0.06000000000023. How is this even possible?

    #2
    This shouldn't be possible with standard bars or candles. Are you using a 3rd party bar? Not all developers of bar types will use Round2Ticksize (NT7) and you may need to add code that to your strategy.

    Dan
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      No, I am using a standart 3 minute chart, nothing else. It works normally most of the time, this is the only case I found. It seems to be a bug.

      Comment


        #4
        Hello TJohn,

        Thank you for your inquiry.

        The reason why this is occurring is because you are subtracting two doubles. Doubles are a floating binary point datatype.

        I suggest reading this particular question on Stack Overflow that goes in-depth with this: http://stackoverflow.com/questions/9...45000000000001

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

        Comment


          #5
          So a cast like this should solve the problem?

          (decimal)(High[0] - Low[0])

          Comment


            #6
            Instrument.MasterInstrument.Round2TickSize(High[0] - Low[0]);
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment


              #7
              Originally posted by TJohn View Post
              So a cast like this should solve the problem?

              (decimal)(High[0] - Low[0])
              A cast will not fix the issue as you are essentially just changing the already erroneous value to a decimal type.

              eDanny has provided an excellent solution that will solve the problem for you:

              Originally posted by eDanny View Post
              Instrument.MasterInstrument.Round2TickSize(High[0] - Low[0]);
              Zachary G.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by burtoninlondon, Today, 12:38 AM
              0 responses
              10 views
              0 likes
              Last Post burtoninlondon  
              Started by AaronKoRn, Yesterday, 09:49 PM
              0 responses
              14 views
              0 likes
              Last Post AaronKoRn  
              Started by carnitron, Yesterday, 08:42 PM
              0 responses
              11 views
              0 likes
              Last Post carnitron  
              Started by strategist007, Yesterday, 07:51 PM
              0 responses
              14 views
              0 likes
              Last Post strategist007  
              Started by StockTrader88, 03-06-2021, 08:58 AM
              44 responses
              3,983 views
              3 likes
              Last Post jhudas88  
              Working...
              X