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

Something wrong whenever I try with dataseries

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

    Something wrong whenever I try with dataseries

    Hello ninjas

    this could be and should be a very easy situation to solve:

    I'm working with very simple formulas based on Close[0], Close[1], median [0], median[1]....etc

    I've developed an indicator to chart it with range bars charts, so I'm trying to backtest it..the problem is when I try to calculate something like this (example) :

    if indicator[1]>0 && indicator[0]==0 and I have no results when actually there are a lot of cases that match my conditions, formulas...etc. I thought thet it could be the floating point issue but it's not.

    I've tried change <>== but the results don't make any sense for the data

    For even odd situation I tried to do a new strategy, same formula, but without non related variables, formulas and surprisingly come out with some results...really I don't get it

    I have good enough experience backtesting, developing formulas but I'm stuck with this.

    Thanks in advance

    #2
    Hi pstrusi,

    Here are a couple pointers that may help you identify what's happening.
    1) Have the strategy add the exact same indicator for visualization. You can do this in the condition builder by checking the box "Add to chart" when defining your condition. To add by code, please see the following link:


    2) Add drawing objects to your conditions so you can easily spot when it's true. See this post for a couple examples:


    If your indicator values look good and your condition shows true on the chart, next step is to see how the strategy respond to your order commands. For this, add TraceOrders = true; to Initialize() method, and then view output under Tools > Output window. This post can help further with TraceOrders usage.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I'll run different trials with your suggestions...i'll let u know hot it goes. thanks a lot

      Comment


        #4
        By the way:
        Are there any suggestions, precautions...etc to have in mind whenever you work with dataseries, running a lot of comparations among x[0], x[1], x[2]...etc ?

        Under what conditions won't these comparations work?

        Comment


          #5
          Here you go a little but clear example what I deal with:

          Below you can find two conditions under same variables, timeframe...etc

          This one forks just fine:
          if (Close[0]-Median[0]>0)
          {
          // do whatever
          }

          BUT IF I ADD THIS:

          if (Close[0]-Median[0]> Close[2]-Median[2])
          {
          // do whatever
          }

          Despite there are a lot of cases I have non result, why?

          Comment


            #6
            Even more odd yet, if I add this simple condition:

            if (Close[2]-Median[2]> 0)
            {
            // whatever
            }

            I have non results

            What and how should I set conditions in order to be able to work with Close[2], Median[2], High[2]...etc?

            Comment


              #7
              Originally posted by pstrusi View Post
              By the way:
              Are there any suggestions, precautions...etc to have in mind whenever you work with dataseries, running a lot of comparations among x[0], x[1], x[2]...etc ?
              Yes, please have a look at this post:


              If this is what you're running into, you'll see index out of range errors in the log tab of the control center.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Yep, that was the reason, thanks a lot

                Comment


                  #9
                  Originally posted by pstrusi View Post
                  Even more odd yet, if I add this simple condition:

                  if (Close[2]-Median[2]> 0)
                  {
                  // whatever
                  }

                  I have non results

                  What and how should I set conditions in order to be able to work with Close[2], Median[2], High[2]...etc?
                  Code:
                   
                  if (CurrentBar < 2) return;
                  at the start of OnBarUpdate(), to escape the exception condition?

                  Comment


                    #10
                    Yep Koganan, it was solved yesterday. I was working with an old code and I forgot to change barsrequired to more than 1.

                    Thanks

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by algospoke, 04-17-2024, 06:40 PM
                    5 responses
                    45 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by arvidvanstaey, Today, 02:19 PM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_Zachary  
                    Started by mmckinnm, Today, 01:34 PM
                    3 responses
                    5 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by f.saeidi, Today, 01:32 PM
                    2 responses
                    8 views
                    0 likes
                    Last Post f.saeidi  
                    Started by alifarahani, 04-19-2024, 09:40 AM
                    9 responses
                    55 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X