Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fire Event to call OnBarUpdate manually

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

    Fire Event to call OnBarUpdate manually

    Hi, I am trying to implement my own data series, and i guess OnBarUpdate won't be called without firing an event. There's no instrument set, because I want to calculate values for higher time frames. Most certainly it won't work, but i'll give it a try. Thanks

    #2
    OnBarUpdate is only called when loading some historical data or on incoming real time ticks.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      The way i interpret your post is that, OnBarUpdate is not called by an event, but is invoked in the code? Is there any way to tell an indicator that there is new data available?

      Comment


        #4
        Sorry to mislead you. The method is invoked by the event of incoming data whether the data is historical or real-time data.

        If you could please elaborate more on what you mean by "no instrument set" perhaps I can help think about possible workarounds to achieve what exactly you are trying to accomplish.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          The problem is that i have an indicator which uses several time frames. If i'd use a normal DataSeries the count would be as much as the chosen time frame. That's why i constructed my own DataSeries with a null indicator and the data stored in a list, and update them with a new value when n-bars have been printed. So far the indicators aren't complaining but since there is no data and get/set can't be overriden, it's just hidden, they will sooner or later. I think it simply can't be done with a DataSeries, so i am intending to writing methods instead of using pre-defined indicators and feeding them the data manually. My C# and NT experience is pretty limited, any suggestions would be appreciated. Thanks

          Comment


            #6
            Mm. Perhaps you could just use a NinjaScript strategy instead? You could just load up a strategy onto your chart and in your strategy just code it like an indicator instead of a strategy. In a strategy you can sync the DataSeries to whatever time frame you need the data from. Please see this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3572

            Alternatively, have you considered writing out the data/calculations to a txt file and then just reading the data and using various time frames in that fashion? You might have issues with read/write operating on the same file object at the same time though so your mileage may vary with this approach. Here are reference samples related to this endeavor:
            http://www.ninjatrader-support.com/v...ead.php?t=3475
            http://www.ninjatrader-support.com/v...ead.php?t=3476

            Perhaps you could mess around with how Gumphrie did multi-timed framed indicators on this one here:
            http://www.ninjatrader-support.com/v...7&postcount=43

            Hope that gives you some ideas.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thank you very much Josh for writing all this. I'll post the results if i can get my indicator to work. Right now the strategy seems to the easiest to accomplish what i have in mind, but can't say for sure.

              Comment


                #8
                My pleasure. Good luck.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Unfortunately the strategy doesn't allow me to draw anything on the chart(maybe it does, but that is what i think ).

                  Gumphrie didn't use NT indicators in his multi time frame approach, so he didn't have to deal with the DataSeries problem.

                  I opted for reimplementing the indicators MIN, MAX, SUM, EMA, SMA, RSI, CCI, MACD and Stochastics so they could work without the DataSeries.

                  The results have been barely tested but the values matched the ones of the original.

                  The whole indicator can be found here.

                  Comment


                    #10
                    Hi Rollins,

                    I thought you might find some interest in this property: Update()
                    I have never used it before, but it seems like it might be fitting for your needs.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Great stuff, appreciate it! Too bad that I didn't know this when I coded the indicator. This stuff might come in handy somewhen.

                      Comment


                        #12
                        Update() Description in Help

                        Is that a typo in the Update() help description?

                        It currently says,

                        Code:
                        tripleValue = 0;
                        
                        private double 
                        protected override void OnBarUpdate()
                        I'm wondering if it should really say something like this:

                        Code:
                        private double tripleValue = 0;
                         
                        protected override void OnBarUpdate()
                        Thanks.

                        Comment


                          #13
                          You are right. Thank you for catching this.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            If we code a strategy like an indicator, how do we get it to plot the indicator on the chart?
                            I tried using the indicator code to create the plot:
                            Add(new Plot(penMotionLine,PlotStyle.Line, "tradingML")); but it would not compile. I assume it is because the strategy does not inherit any of the indicator methods. If this is so, is there a way to plot the indicator from within the strategy?

                            Comment


                              #15
                              You can add indicators to the strategy by doing something like
                              Code:
                              Add(SMA(5));
                              http://www.ninjatrader-support.com/H...uide.html?Add1
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Anthony_0709, Today, 01:29 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by kenbun, Today, 12:21 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post kenbun
                              by kenbun
                               
                              Started by WNorton, Today, 11:23 AM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Spencer  
                              Started by stafe, Today, 10:43 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post stafe
                              by stafe
                               
                              Started by UltraNIX, Today, 09:13 AM
                              3 responses
                              18 views
                              0 likes
                              Last Post UltraNIX  
                              Working...
                              X