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

Accessing an indicator without passing Bars object

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

    Accessing an indicator without passing Bars object

    Hi.

    Can I access an indicator variable without passing a Bars object to it and without having it using the base chart Bars object?

    I aim to like access an indicator variable and have the indicator access an instrument by itself. I need it due to the lack of possibility to control the number of bars of an added Bars object via strategy script.

    More here: http://www.ninjatrader.com/support/f...98&postcount=1

    Maybe an option could be loading the indicator to an independent chart and access its var from another script loaded on another chart, if that's possible.

    #2
    Sorry savekad, I'm not following what you wish to here - the indicator itself could add it's own series and instruments for sure and you could access this indicator then in your strategy - yet dynamic adding of series would be something we could not fully support.

    In a MultiSeries environment you will see the OnBarUpdate() called when BarsRequired has been satisfied for all involved series in your script.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yeah I guess I wasn't really clear with that example. Let's say that I have an indicator which adds two bars objects and calculates several variables for each.

      I want to access all the variables from the strategy but in a way that the indicator operation will be independent and not affected by the strategy code. In other words, I want to avoid calling Update() at each variable access and I want the indicator OBU() method to iterate all the bars of its added bars objects as if the indicator is directly loaded to a chart and not subjected to the strategy OBU() method.

      Comment


        #4
        If you want to avoid the Update() calls, why not expose the values needed as DataSeries then?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Because I use List<double> which have a small number of elements and the DataSeries collections are always sync their length with the number of bars presented on the chart.

          Comment


            #6
            So, this would be a performance / memory concern - the default DataSeries in NT would limit itself to a lookback of 256 which is sufficient for most scenarios - http://www.ninjatrader.com/support/h...ries_class.htm

            I would suggest working with this approach.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I can't use it as I need full control and awareness of the collection size. I can't let it dynamically stretch itself with every new bar being opened.

              I will come with a more practical problem when I will encounter it again.

              Comment


                #8
                Originally posted by savekad View Post
                Because I use List<double> which have a small number of elements and the DataSeries collections are always sync their length with the number of bars presented on the chart.
                Calling Update() when you access the getter is the only way to ensure that you have current values. That is just one of the caveats of event-driven programming. NT ensures that Plots always have current values: other entities will need the Update() if you want accuracy. If you have already decided to use a construct that you think is more efficient anyway, then calling Update() is already optimized by what you have done.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by knighty6508, Today, 01:20 AM
                1 response
                6 views
                0 likes
                Last Post brucerobinson  
                Started by franatas, Today, 01:53 AM
                0 responses
                1 view
                0 likes
                Last Post franatas  
                Started by knighty6508, Today, 01:17 AM
                0 responses
                6 views
                0 likes
                Last Post knighty6508  
                Started by tierraany, Today, 01:06 AM
                0 responses
                4 views
                0 likes
                Last Post tierraany  
                Started by Wilmarobyi, Today, 12:48 AM
                0 responses
                3 views
                0 likes
                Last Post Wilmarobyi  
                Working...
                X