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

2 Big issues when operating with simple prices, non-sense at all

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

    2 Big issues when operating with simple prices, non-sense at all

    Hi Ninjas,

    I've found apparently two important issues, which make my backtesting's results simply non-reliable, and don't know how to address them correctly. Before problem description, I work with NT version 7.0.1000.27.

    I work with EURUSD, which goes in half-ticks ( 0.00005 ), generally in range bars charts. Here the 2 issues:

    1. The result of simply operations like for example this: 2*Close[0]-Median[0]-Open[0] gives a number which is not in the exact format of half-pips , fix 5 digits after decimal point,BUT a number until 16 digits after decimal point, which it shouldn't be with this simply math. It seems the typical floating point problem, SO, in order to address it, I tried to use Math.Round(x,n) BUT then I came across with the other issue

    2. When I use Math.Round(x,16) ( until 16 digits after decimal point ) , then an error pops out when I run the backtesting:
    Error on calling 'OnBarUpdate' method for strategy 'STSdiffOriginal/daa2d411202e4d5cbde915766cd814c9': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 Which is non-sense, because this Method has nothing to do with this message, besides my barsrequired are by far longer than used in the Algo.

    I've done several trials with and without Math.Round, with different digits, and the backesting results are just chaotic, not even close.

    I'd like you to address this problem, cause I can't work it out by my own.

    Looking forward for your help, thanks
    Last edited by pstrusi; 05-27-2015, 05:25 AM.

    #2
    2 ideas

    Try nt's round2ticksize function.
    And try a currentbar check if that doesn't help.

    Comment


      #3
      Hi pstrusi,

      The long double is coming from the Median.

      While when printed this is rounded, it is a calculation that is not a tick size.

      Try (2*Close[0]-Open[0]). Without the Median this should print to a tick size.

      From the help guide:
      Median price = (High + Low) / 2

      http://www.ninjatrader.com/support/h...nt7/median.htm

      This number is very seldom an actual tick size.


      Sledge has a good suggestion of using Instrument.MasterInstrument.Round2TickSize(). However, if you round the median, it will no longer be the median. Is this how you are intending to use this number?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hi Chelsea and Sledge, thanks for your responses and sugestions.

        As always when I find a partial solution, I post it:

        - I've realized that you have non-sense unexpected decimal numbers, when you do operations with variable of different types, for example: you do a simple math function with an integer and a double, and you're expecting a double number to come up. so, SUGGESTION: do math operations and comparisons with same type of variables.

        - Apply a solid logic and better to set parameters far enough to include the minimum difference in the right set of results
        Last edited by pstrusi; 05-27-2015, 07:11 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Kaledus, Today, 01:29 PM
        0 responses
        3 views
        0 likes
        Last Post Kaledus
        by Kaledus
         
        Started by PaulMohn, Today, 12:36 PM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by yertle, Yesterday, 08:38 AM
        8 responses
        36 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by rdtdale, Today, 01:02 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by alifarahani, Today, 09:40 AM
        3 responses
        18 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X