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

Loading custom historical data from secondary instance

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

    Loading custom historical data from secondary instance

    Hello,
    I have written an indicator which records changes in the book depth and writes these too a Sqlite database so a historical book record can be achieved. It loads the data series from the database during State.Transition and all this works fine. However i would like to use the information in a new indicator which calls an instance of the book change indicator as part of its calculation. Ive tried a few things but have had no success in getting the history to be read into the calling indicator. Real time is of course fine. Is this something that could actually be done?

    Thanks

    #2
    Hello cdsmart,

    Thank you for your post.

    Do you get any errors on the log tab of the Control Center when attempting to load the data in the host indicator? You may need to consider the concepts demonstrated in the following reference sample for exposing indicator values that are not plots:


    There is a note about hosted indicators on the following page:
    • https://ninjatrader.com/support/help...nbarupdate.htm
      • "Hosted indicators will need to be accessed by the hosting script to ensure OnBarUpdate functionality. This can be done by: 1) Calling Update on the hosted indicator within the host script, 2) Including a plot in the hosted indicator and accessing the plot in the host script, 3) Including a plot in the hosted indicator and adding the indicator to the chart with AddChartIndicator (strategies only)​"
    You may need to call Update() or add a plot to the hosted indicator and access the plot in the host script in order to have these values update as expected in the new host indicator.

    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply Emily,

      There are no errors, the indicator runs flawlessly in real time. The issue is attempting to use the History stored in the SQLite db that in the hosted indicator is loaded to Series<double>s in State.Transition (this is the only state i seem to be able to load directly to Ninja Series without error, got that tip from a Dev in here). The values are stored in Plots (Value[0] etc) and load very quickly in the Hosted indicator. There is also another value in there which is exposed as per your link above using the assignment in the Properties but im not worrying about that ftb as using Plots seems like it will be a less complicated way to sort out my issue. I tried your Update() suggestion by putting this in the hosting indicators' State.Transition but to no avail. Not sure if I'm understanding you correctly about calling it on the actual hosted indicator. As i say, the plots are perfectly accessible when in real time, just none of my history which loads into the hosted script at transition is anywhere to be found in the host script?

      Thanks

      Comment


        #4
        Hello cdsmart,

        Just to confirm, the data is being assigned to a plot series (Values[0]) and is plotting on the chart?

        The Values[0] series is being returned by a public series in the getter?
        I'm trying to expose my variables to the strategy builder so everyone can have better use of the WaveTrend indicator (it has a lot of code). Explain this to me like I am 5 because this isnt the first time I've tried to figure it out and hit a wall. What is Series? I know its like an array that stores bars. Why not just call it


        But when you call the symbiote indicator from a host in OnBarUpdate(), the public series is returning a 0?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          What you have stated above is correct except that the hosted indicator only returns zero for historical bars, It returns correctly in real time. In the hosted indicator during state.transition the database file is read and the data is matched using Bars.GetBar to the corresponding barsAgo value of the publicly accessible Series (Value 0)

          [Browsable(false)]
          [XmlIgnore]
          public Series<double> BookClose
          {
          get { return Values[0]; }
          }

          It seems the issue is the sqlite db historical data loading into the hosted script does not make it through to the host script. It would be good to know why as i have other scripts that could take advantage of a solution for this issue.

          Thanks​

          Comment


            #6
            I managed to get it working by making the db load method publicly available then calling that at State.Transition in the host script. If you know any other more elegant ways to achieve same please let me know,

            Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            16 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            4 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,785 views
            0 likes
            Last Post Leafcutter  
            Started by poplagelu, Today, 05:00 AM
            0 responses
            3 views
            0 likes
            Last Post poplagelu  
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,407 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Working...
            X