Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Very slow exection in V7

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

    Very slow exection in V7

    By adding a bar series to a strategy and referencing the added series with an indicator made the strategy run 100x slower? Was this expected?

    Situation::
    To a chart with a 5 min data bar I added a strategy that had a 60 min bar of the same symbol and used the 60 min bar with an indicator. Before adding the 60 min bar the strategy ran in 1 sec on 25 days of data. After adding the 60 min bar and indicator reference it the strategy ran in 3 min.

    On a strategy that only used one data bar and the indicator it runs in 1 sec so it was not the indicator that caused the problem.

    #2
    Hi GuyFB,

    Did you perhaps mean that you created an indicator then referenced it with a strategy?

    Can you please clarify the process so that I can test/evaluate this on my end.
    TimNinjaTrader Customer Service

    Comment


      #3
      Tim,
      Yes, But I think you could use almost any indicator. I did use one I have created and it process the bar data.
      1) Ran Strategy without adding bar data. Ran 1 sec
      2) Added to strategy:
      Add(PeriodType.Minute,60);

      If (barsInProgress == 0)
      {
      Processing that was there on first run
      }
      else
      {
      Access indicator with BarsArray[1] as input
      }
      Run time is now 4 min.

      This is place on a chart with 5 min bars

      Have code if you need it.

      Comment


        #4
        Hi GuyFB,

        Can you please provide the relevant code snippets you are using, so that I can test this on my end.
        TimNinjaTrader Customer Service

        Comment


          #5
          Tim,
          The attached Strategy uses the three indicators that are attached. Load the strategy on a 60 min chart. It will add a 10 min bar for that data.

          The indicators, TrendTrange and PMAInd are called twice. Once for the 60 min data and also for the 10 min data. If I run the two on just 10 min or 60 min in a strategy that does not use a second bar set the execution is 1 sec.

          In this case where both are use together the time is 4-5 min. I was testing on a chart with 20 days of 60 min bars.

          Your help will be appreciated.
          Attached Files

          Comment


            #6
            Hi GuyFB,

            I am willing to briefly test this on my end to see if I am able to reproduce the scenario you mentioned. However, this did not compile correctly, it seems the strategy is calling on "TrendRange"....and "RangeTrend" is the attached indicator. A simple rename did not correct errors.

            While I won't be able to debug this for you, if you are able to break it down in to smaller, simple examples, I can offer you advice based on that.
            TimNinjaTrader Customer Service

            Comment


              #7
              Woops! picked up the wrong one. Here it is. Lets see if you can spot something with this.
              Attached Files

              Comment


                #8
                Hi GuyFB,

                I tried this on my end and it loaded it just over 2 minutes.

                Be sure to check your code for any recursive methods used.

                Also try this without adding the extra time frames, and without plotting the extra panels.
                TimNinjaTrader Customer Service

                Comment


                  #9
                  Tim,
                  Two min. is a life time when trying to enter/Exit a market.

                  I have now found my problem but I need a bit of help understanding calls to indicators when they are called from a strategy that has Added Bar Series.

                  When I call the indicator without the Add it is executed once for each bar from the chart with CurrentBar = 0.

                  When I call the indicator WITH the Added Bar Series and reference the added series it is called for each bar in the chart. However the call is a loop that starts with CurrentBar = 0 pointing to the first added bar then continues calling the indicator until CurrentBar equal the look back period. Then the BarsInProgress = 0 routine is executed and the loop begins again passing CurrentBar = 0 up to the present.

                  So for each bar on the chart the indicator that references the Added data is called (LookbackPeriod + n Factorial) times where n is the currentbar of the chart.

                  Obviously the indicator need only execute for the last current bar but How do I tell it to do so? Why is this not done in other indicators? What is the logic in calling the indicator so many time?

                  I can send you a printout showing the looping process if this is not clear.

                  Comment


                    #10
                    Hi GuyFB,

                    Could you please provide the relevant, simple snippet(s) of how you call the indicator, where you suspect it is calling it multiple times.
                    TimNinjaTrader Customer Service

                    Comment


                      #11
                      It was a NJ V7 problem

                      Tim,
                      I found what was causing multiple loops of the call indicator from a strategy when you add Bars with a different time frame to the strategy.

                      The indicator had these two statements in it. I commented them out and it works fine now. I think there is a problem with V7 or some comment should be made in the documentation to warn people not the use this combination.

                      PriceTypeSupported = true;
                      PriceType = PriceType.Median;
                      Guy

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by jaybedreamin, Today, 05:56 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post jaybedreamin  
                      Started by DJ888, 04-16-2024, 06:09 PM
                      6 responses
                      18 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by Jon17, Today, 04:33 PM
                      0 responses
                      1 view
                      0 likes
                      Last Post Jon17
                      by Jon17
                       
                      Started by Javierw.ok, Today, 04:12 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post Javierw.ok  
                      Started by timmbbo, Today, 08:59 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post bltdavid  
                      Working...
                      X