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

Calculate all values at once

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

    Calculate all values at once

    Hi,

    the more I read about NT, the more I see it's potenials!

    One Question:
    The calculation of an indicator happens iteratively, i.e. from the first to the last period the calulation is done.

    Suppose I want to calculate all given values at once - not beginning with the first, second etc. - but take all available values and make an all over calculation.
    For example a given time series with 10.000 values.
    Normally the indicator would calculate from 1 to 10.000. What I want to to is make only the calculation for 10.000 set the wright return values. When new data arrives I only need to calculate the last new period.

    Is that anyhow possible with NT?

    Regards

    Martin

    #2
    What is your purpose? What are you trying to achieve this way?

    --EV

    Comment


      #3
      Hi EV,

      my purpose is simply that I want to reuse an existing indicator, written for the system "Investox", with as little modifications as possible.

      Martin

      Comment


        #4
        Well, I guess "yer pays yer money an yer takes yer choice". You either put in effort trying to shoehorn a foreign design in or you put in effort modifying it to fit gracefully. I don't know how the indicator in question is designed, but how about the following:

        When OnBarUpdate() gets called the first time, you treat that as all the history there is. That should get you initialized. Then treat all succeeding bars as if they were new real-time input. With any luck, that would require minimal changes to the code you are porting and would fit in well with NT.

        I could be wrong, but I suspect your best path is to see how little work you can do to fit in as NT is designed.

        --EV

        Comment


          #5
          Hi EV,

          thanks for the advice. I did not mention one crucial reason. The Indicator is calling a central server via WCF. In runtime of the system this is no problem. cause the latency of the wcf-call is acceptable. In design-time the problem increases, since long backtest become more time-consuming.

          Regards

          Martin

          Comment


            #6
            I see ... as I understand it, there is an expensive event that has to happen, It can happen for once for each bar (slow) or once for all bars. Right?

            The support folks may correct me, but is there a reason you cannot just return from OnBarUpdate() without doing any work until you get called for the last bar? Would not waiting until the last bar to do your work meet your original request?

            As new bars arrive after that, you would know because History would be false.

            --EV

            Comment


              #7
              Hi EV,

              that's the way I want to try it out, the only question is, how can I recognize the last bar? In BackTest I will always get history-data.

              Regard

              Martin

              Comment


                #8
                I wondered whether that would be the next question. I have seen posted:

                Code:
                if (CalculateOnBarClose) {
                       if (CurrentBar == (Count-2)) <this is the last bar>
                  } else {
                       if (CurrentBar – (Count –1)) <this is the last bar>
                I believe that the following also works, and is simpler:

                Code:
                if (    CurrentBar == LastBarIndexPainted) <this is the last bar>
                Any comments from someone from support?



                --EV
                Last edited by ETFVoyageur; 01-15-2011, 09:18 AM.

                Comment


                  #9
                  Hi EV,

                  your hint with
                  if ( CurrentBar == LastBarIndexPainted) <this is the last bar>
                  is working!

                  Thanks for your great help!

                  Martin

                  Comment


                    #10
                    You are most welcome. Glad to be of help.

                    --EV

                    Comment


                      #11
                      Guys, glad to hear you got it figured out. Please let us know if you have any other questions. As a side note, LastBarIndexPainted is unsupported, but it is very useful.
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Austin View Post
                        Guys, glad to hear you got it figured out. Please let us know if you have any other questions. As a side note, LastBarIndexPainted is unsupported, but it is very useful.
                        FWIW: LastBarIndexPainted is used in NT's V7 Heiken Ashi indicator. I realize that does not make it supported ....

                        --EV

                        Comment


                          #13
                          When testing, use the simulated feed or the Market Replay Data feed to create a quasi realtime feed in either case.

                          This code will ensure that at all times, no matter when you load the indicator, only real time values will be calculated.

                          Code:
                          if (Historical) return;
                          // rest of the code goes here
                          Last edited by koganam; 01-15-2011, 09:28 PM.

                          Comment


                            #14
                            Originally posted by ETFVoyageur View Post
                            FWIW: LastBarIndexPainted is used in NT's V7 Heiken Ashi indicator. I realize that does not make it supported ....

                            --EV
                            A quick definition of unsupported that holds 99% of the time: if you can find it in the help guide, it is supported. If it is not in the help guide, it is unsupported.
                            AustinNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by halgo_boulder, Today, 08:44 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post halgo_boulder  
                            Started by drewski1980, Today, 08:24 AM
                            0 responses
                            3 views
                            0 likes
                            Last Post drewski1980  
                            Started by rdtdale, Yesterday, 01:02 PM
                            2 responses
                            17 views
                            0 likes
                            Last Post rdtdale
                            by rdtdale
                             
                            Started by TradeSaber, Today, 07:18 AM
                            0 responses
                            7 views
                            0 likes
                            Last Post TradeSaber  
                            Started by PaulMohn, Today, 05:00 AM
                            0 responses
                            10 views
                            0 likes
                            Last Post PaulMohn  
                            Working...
                            X