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

Using external historical data as indicator values

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

    Using external historical data as indicator values

    I'm calculating some outside independent values that I'd like to use in strategy development. I'd like to use it as an indicator though, so I'll be able to show it on the charts, and use it as I do some of the other indicators for the strategy. Thus I have created an outside program to create an appropriate data format to import into Ninja using the Import -> Historical Data methods.

    It appears that the default setting is for Instrument to be a STOCK.

    My question is this, how do I best get this new information into my indicator. I am trying to write a custom indicator for this purpose, which will just call:

    AddDataSeries("MY_CUSTOM_CALC");

    I have looked at the data on a daily chart, and the values are what I put in the file. But when I try to use it with a daily future I seem to have issues with when the data is called with respect to the BarUpdates being out of order. Sometimes it even appears that the custom bar is not called on BarClose (specifically with the last datapoint in the custom series).

    I have played around with the Instrument settings for the Custom Series by changing the Trading Hours to match or just offset the ES futures. I've also looked at it against a regular stock like AAPL, and I still don't see the last data point. In the output screen, it appears that it's not calling that specific bar.

    This may not be enough information to debug I realize, but wondering if this is a good approach in general or if there's another suggestion to approach the problem: basically I have an externally calculated indicator (daily in this case) that I'd like to have available as an indicator. Perhaps just loading the data from the custom indicator itself (and avoiding the Historical import) would be better?

    Open to ideas & suggestions. Thanks.



    #2
    Hi mohawkTrader, thanks for posting.

    It's not conventional to use the Import function like this, but it should work as long as the data follows the correct formats here:
    https://ninjatrader.com/support/help...AndDataFormats

    This would need to be tested thoroughly since the data is not conventional instrument data. The best way of doing this would be to gather the information in an indicator in State.DataLoaded or State.Configure into a List or a data structure of your choosing or load it into a Series<T> object that does a lot of the organizational work for you:
    https://ninjatrader.com/support/help...ml?seriest.htm

    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks ChrisL.

      The date format is correct, as I can import the custom indicator into a chart without problem. I'll look into it further, but I'm thinking it may have something to do with the Trading Hours or similar. Is there any scenario where the OnBarClose will not be called for a particular bar for a particular data series that is added? For instance, if ExitSession or something similar is called?

      I do think using the import would be the simplest because then in theory the data is organized for me.

      If using the Series<T> object directly, and populating it, do you have examples that match up dates? Since you'll have to back calculate how many bars ago for a particular point. This is fragile when one or the other data series may be missing a point (holiday, missing data, etc) and so they won't necessarily match up without cross checking both dates. Do you have a recommendation for performing this cross check using the Series objects? That is, the data being operated on, the primary series and then the new custom series being created?

      From the guide:
      Setting Values


      You can set the value for the current bar being evaluated by choosing a "barsAgo" value of "0" or, for historical bars, by choosing a "barsAgo" value that represents the number of bars ago that you want the value to be stored at.

      Thanks.

      Comment


        #4
        Hi mohawkTrader, thanks for your reply.

        I do not have an example demonstrating this specifically. One important factor of the Series<T> object is that it will always have the same amount of bars as the BarsArray[] that you pass to it, so it makes it easy to store a custom data point for every bar on the chart. The best way of importing the data into an indicator would be to use a StreamReader or System.IO to read from a .txt file. Here are some examples:
        https://ninjatrader.com/support/help...o_read_fro.htm
        https://ninjatrader.com/support/help..._propertie.htm

        Kind regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by [email protected], Today, 06:30 PM
        0 responses
        1 view
        0 likes
        Last Post bpatel20@gmail.com  
        Started by akm39, Today, 04:31 PM
        5 responses
        51 views
        0 likes
        Last Post akm39
        by akm39
         
        Started by Giorgetto, Today, 02:15 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by WalterSkinner, Today, 01:39 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by ernest93, Today, 01:08 PM
        1 response
        20 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Working...
        X