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

How do I modify Pivot indicator to only use Historical Data

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

    How do I modify Pivot indicator to only use Historical Data

    I use a pivot indicator which is the same as the Built in Ninja Floor Pivot indicator.

    1) I use it with daily bars set as the input setting.
    2) I use the kinetick data feed to populate daily charts and obtain the correct high , Low and settlement closes. and then those charts are closed as I now have the historical data I need for the day.
    3) If I uncheck "Get Data drom Server( if available)" it works but If I leave it checked My real time feed will write over the Daily History data collected even tho the daily charts are closed because of the data method that reads the data in the indicator. Note: The Pivot indicator is applied to intraday tick charts.

    So it works to some degree with this limitation of unchecking "Get data from Server" But
    The major problem with this is that I have another indicator that doesn't work properly unless "Get data from Server ( if available )" is checked.

    So I would like to modify the Pivot indicator to only use Historical data and to not Fetch any data from the server that would overwrite the daily history data. I can read and write "C" code but I don't know the internals and the appropriate commands Functions in Ninja to make this modification if possible. I have tried commenting and changing sections I thought might correct it but all to no avail. Can someone either give me some direction on this or provide some links to code that will only read the historical data without pulling in data from the server.

    The pivot indicator is built in and you can examine the code, so I did not post it.

    Jerry
    Last edited by JerryWar; 04-16-2011, 01:19 PM.

    #2
    Jerry, please add in this line at the very top of the OnBarUpdate() method:
    if (!Historical) return;

    This will basically force your indicator to skip over all data that is not historical.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Austin View Post
      Jerry, please add in this line at the very top of the OnBarUpdate() method:
      if (!Historical) return;

      This will basically force your indicator to skip over all data that is not historical.

      Austin
      That's awesome, I have made the change and will test it on Monday when real time data starts coming in.

      thanks.
      Jerry

      Comment


        #4
        Originally posted by NinjaTrader_Austin View Post
        Jerry, please add in this line at the very top of the OnBarUpdate() method:
        if (!Historical) return;

        This will basically force your indicator to skip over all data that is not historical.

        Austin
        This did not work, I have just tried it The close of Friday got written over with "Get data from Server" Checked and no daily charts up with your code line added. below is a snippet of what I added. Do you have any other ideas ?

        protected override void OnBarUpdate()
        {
        // Don't update unless historical data.
        //
        if (!Historical)
        return;
        if (Bars == null)
        return;
        if (!Bars.BarsType.IsIntraday && Bars.Period.Id != PeriodType.Day)
        return;

        Comment


          #5
          Jerry, I am not sure if this is actually possible upon reconsideration. I will have someone get back to you tomorrow.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Hi Jerry, this is unfortunately not possible without changing the internal workings of the per default shipped code as it would asyncronously load the needed series in the GetBarsNow() method outside of OnBarUpdate(). If you change to code to not trigger this method to update the daily base date it should come close to what you seek here.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Hi Jerry, this is unfortunately not possible without changing the internal workings of the per default shipped code as it would asyncronously load the needed series in the GetBarsNow() method outside of OnBarUpdate(). If you change to code to not trigger this method to update the daily base date it should come close to what you seek here.
              Bertrand
              Hi good to hear from you again. I understand what your saying except that as when you remove the call to GetBarsNow() it looks like it no longer fills the DailyBars Data structure so there is no data to calculate the pivots. How do I retrieve the history in this case. I tried playing with the parameters in Getbars but got no where and I could not find any definition on your site.That appears to be the offending line of code in the method. Can the parameters be tweaked or does there need be a different method to read the history. If so could you point me in the right direction ?

              Thanks
              Jerry
              Last edited by JerryWar; 04-18-2011, 10:17 AM.

              Comment


                #8
                Hi Jerry - then I'm not following what you attempt to do - if you remove the GetBarsNow it should not grab any backfill data - which is what you seemd to seek here according to your first post? The method used is unfortunately not documented and therefore not supported, it's a custom method only designed for the use in this exact script.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  Hi Jerry - then I'm not following what you attempt to do - if you remove the GetBarsNow it should not grab any backfill data - which is what you seemd to seek here according to your first post? The method used is unfortunately not documented and therefore not supported, it's a custom method only designed for the use in this exact script.
                  Betrand
                  Let me restate the issue.
                  I use kinetick EOD data to supply the daily data for the pivots indicator. I load this indicator on an intraday chart. So each morning I open a daily chart while connected to kinetick and update the daily data. Then close that Daily workspace and close the kinetick connection. I then connect to my broker. With the pivots indicator, If you don't uncheck Get data from Server ( if available ) Even tho a Daily chart is not open it will overwrite the EOD bars that were saved from Kinetick. I think Because of the way the indicator is written Ninja will use intraday data from the broker to calculate eroneous EOD bars and write over the last one or two daily history bars loaded from Kinetick messing up the pivots. The downside of unchecking Get data from server is that Other indicators do not work properly.

                  You are correct when you say eliminating GetbarsNow will stop the backfill of the history data. It does. But it also no longer plots the pivots because I think that it is also how it transfers the data from the history database to the memory structure used to calculate the pivots. So what I am asking is how do I load data from the history database(data that is already there) for calculation of the pivots without GetbarsNow.

                  Thanks
                  Jerry
                  Last edited by JerryWar; 04-18-2011, 10:55 AM.

                  Comment


                    #10
                    Thanks for the clarification Jerry, have you tried simply staying connected to Kinetick as primary connection and then connecting to your broker second and working with 'Get Data From Server' - this way for any request triggered the daily bars should still come from Kinetick where as realtime data not available from it would come from the broker connection.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by bortz, 11-06-2023, 08:04 AM
                    47 responses
                    1,610 views
                    0 likes
                    Last Post aligator  
                    Started by jaybedreamin, Today, 05:56 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post jaybedreamin  
                    Started by DJ888, 04-16-2024, 06:09 PM
                    6 responses
                    19 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by Jon17, Today, 04:33 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post Jon17
                    by Jon17
                     
                    Started by Javierw.ok, Today, 04:12 PM
                    0 responses
                    22 views
                    0 likes
                    Last Post Javierw.ok  
                    Working...
                    X