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

Instrument Name

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

    Instrument Name

    There is a field in the strategy analyzer under Data Series called Instrument. How can I programmatically get that name, other than using the Instrument class object, which is sometimes null when optimizing?

    Thanks!

    #2
    Hello,

    Thank you for the post.

    The Instrument object would be the correct way to retrieve the Instrument the strategy is applied to, but this object can be null as you mentioned. Can you tell me, where are you currently trying to use this where it is null, is this being used from OnStateChange before State.DataLoaded? We do note that this cannot be used in OnStateChange before State.DataLoaded here: https://ninjatrader.com/support/help...instrument.htm

    The object otherwise would have a value after State.DataLoaded and could be used. If you are trying to use this to dynamically add data series, I can add a feature request for that specifically. We do note that dynamically adding series is not possible in the AddDataSeries page warnings: https://ninjatrader.com/support/help...=adddataseries

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Yes, I'm trying to load the chart data series in a strategy to indicators downstream to avoid that ubiquitous "A hosted indicator tried to load additional data..." error.

      I have seen this page you linked to and can't for the life of me understand why you would restrict the API to only being able to hard-code a data series. The indicator I was asked to write relies on the chart data series and it seems to me, I should be able to know what the user set the chart to at any time during the initialization process. (The indicator compares the chart data series to a user input data series.) Nothing changed after all, between right-click -> Strategies and pressing the OK button in the strategy properties to load it on the chart. In other words, all that information is known and should be available.

      However, I think I've figured out a way to load both the instrument name and the bar series settings on the chart when I load the strategy on a chart (and it works in the Strategy Analyzer - backtest too!) The Data Series has all of that information available in the Strategy Analyzer (Optimize). So all I would need is to be able to access those values in the Strategy Analyzer(Optimize). And then of course I would need to know if the Strategy Analyzer is calling. I think a couple of us asked for that a year or two ago or so. I guess I didn't follow up. (I think I wanted to dynamically set certain property's browsable settings to false in the Strategy Analyzer but just never ended up doing that. Not sure what others wanted to do.)

      Is there any way you could make that happen? Hard coding is a big drag and in my world, it seems to me that a strategy should be able to be run no matter how you have your chart set up. I hope I don't have to tell my client, "Sorry, Ninjatrader won't let us code this strategy to run on anything but a 5 minute, YM chart." Either that or, "We don't recommend you optimize this strategy." I'm pretty sure users aren't going to want to hear that.

      So yes, if you could have someone figure out a way for me to optimize my strategy, I would appreciate that.

      Thanks Jesse!
      Last edited by traderpards; 01-11-2018, 02:48 PM.

      Comment


        #4
        Hello,

        Thank you for the reply and confirming you are trying to use dynamic series.

        For this I will put in a feature request, unfortunately I would have no suggestions on how to dynamically add the series as that is advised against. At this time there is no suggested or supported way to do this as it is known that dynamically adding series in this way fails under certain conditions like the optimizer. Once development revisits this topic they can address it further until then I can put in feature requests to add this as an option.

        For the time being, you would need to hard code the added series values as we suggest in the help guide.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse...

          I wonder if I could make those values user variable properties..

          1. Instrument name
          2. Bar type
          3. Bar type value

          That way I could load them in the optimizer. I haven't tried it but it "should" work, right? But since I'm able to load the series info the way I want and it seems to work just fine on a chart and if you backtest in the Strategy Analyzer, I would want to only have that to optimize. I don't suppose you figured out a public method that tells if the optimizer is calling have you? Of course, doing it this way means I can't optimize on the data series but that's OK, I'll take what I can get.

          Thank you for putting in that feature request.

          Comment


            #6
            Originally posted by traderpards View Post
            ... I don't suppose you figured out a public method that tells if the optimizer is calling have you?
            ref: https://ninjatrader.com/support/foru...27&postcount=1

            Comment


              #7
              Hello traderpards,

              Thank you for the reply.

              It is possible to make user properties for those items if they would be used later in the script, but as mentioned in the help guide note they would face the same problem in the early states. The help guide suggests not to use any runtime variable such as user properties or inherited properties as they are currently unreliable in that state. (e.g., Instrument, Bars, or user input)

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kaywai, 09-01-2023, 08:44 PM
              5 responses
              601 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by xiinteractive, 04-09-2024, 08:08 AM
              6 responses
              22 views
              0 likes
              Last Post xiinteractive  
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              17 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              230 views
              0 likes
              Last Post TradingLoss  
              Started by agclub, 04-21-2024, 08:57 PM
              3 responses
              17 views
              0 likes
              Last Post TradingLoss  
              Working...
              X