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

Multi-time-frame indicator: having enough data

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

    Multi-time-frame indicator: having enough data

    I am trying to code a support and resistance indicator based on swing highs and swing lows, not only from the primary dataseries time-frame, for me the 3-min bars, but also from the hourly, daily and weekly time-frames.

    While doing some prototypes, I immediately came across several problems because I need a couple of years of weekly data to get the relevant swing highs and lows from the weekly data.

    The first thing I tried was to load up all the data I need on the 3-min chart where I am deploying the indicator - however having 1000 days of 3-min bars is not very practical. It takes 12 seconds to load not only because I've got half a dozen other indicators besides this one operating on the data.

    I figured I could try applying the indicator to 10 days of 3-min data, as I usually use, and then dynamically load the higher time-frame bars in the indicator. However looking at the code in the Pivots indicator which makes use of the Data.Bars.GetBars() function, I would have to process the looping for the indicator's functionality myself, because the bars from GetBars() do not launch the onBarUpdate() event.

    Can I manually add the bars into the BarsArray somehow so the dynamically loaded data is processed by onBarUpdate()? It looks like coding it manually will require lots of jumping through hoops to do something simple like this:

    Code:
                if (High[2] >= High[0] && High[2] >= High[1]
                    && High[2] >= High[3] && High[2] >= High[4])
    Is there a more elegant way to do this?

    Then after that problem comes another problem: the rectangles that I use to plot the S/R levels just disappear when I am scroll left from the currentBar. See this thread - a known NT7 limitation,

    Instead of drawing the rectangles on the charts myself in the override Plot method, I tried normal Plots. NT7 plots the lines quite happily and they are not affected by this limitation, i.e. the lines are visible all the way to the left-hand side of the chart instead of disappearing. Obviously DrawRectangle() is not the way to go - can I get NT7 to plot rectangles instead of lines? Any examples out there?

    #2
    Hello adamus,

    It is recommended that you use the Add() with static variables, as dynamic variables inside the Add() method can cause some unexpected results and is not supported.

    With that said it is possible, you can view the following indicator that Add() an instrument dynamically.


    As for checking the High[] values, that would probably be the best way. Note that if you are going to check for rising or falling conditions you may use the Rising(), Falling(), NBarsUp(), or NBarsDown() method.

    Please note that limitation can also effect Lines as well. Any drawing object with 2 or more anchor points that are too far away from the visible display on the chart will be effected. You may use Horizontal Line that will not be effected.
    JCNinjaTrader Customer Service

    Comment


      #3
      OK JC, thanks, I'll try out your recommendations.

      While I'm doing that though, my 2nd question was about the limitation *not* affecting plotted lines - i.e. using DrawLine and DrawRectangle hit this limitation - the lines disappear. However I think (and I might be wrong) that leaving NT7 to do the plotting, i.e. not overriding Plot(), results in lines on the chart that don't disappear. They remain on the screen.

      The reason I'm not sure is that it might be a limitation thing that only hits lines when you've got more than 100 on the screen. When I set my indicator to plot the lines automatically by Add(new Plot()) 100 times, then it was all fine.

      Am I right, or do I just need to add 300 lines via Add(new Plot()) to hit the same limitation?

      Comment


        #4
        Hello adamus,

        The Plot Method would not run into this limitation. It will only effect Drawing Objects, like if you use DrawLine() or any Drawing Object (Like the ones that you can manually draw on the Chart) with 2 or more anchor points will be effected.
        JCNinjaTrader Customer Service

        Comment


          #5
          A bit of an elementary question I guess, but can I configure the plot to be a rectangle in some way?

          Comment


            #6
            Hello adamus,

            For that you would have to override the Plot method.
            JCNinjaTrader Customer Service

            Comment


              #7
              OK I can do that, but won't I still have to use the DrawRectangle() function and have the same problem?

              Comment


                #8
                Hello adamus,

                You would not use the DrawRectangle() method you would draw the rectangle in a different method. You may see an example of this by going to Tools -> Edit NinjaScript -> Indicators -> CustomPlotSample.

                Please note this would not be something that we could support, but it would get around the limitation.
                JCNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by andrewtrades, Today, 04:57 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                3 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                7 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X