Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

need to apply Update() on properties

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

    need to apply Update() on properties

    I have been using this indicator for many years and found out today that the properties is not automatically showing correct value in multitimeframe strategies when i apply the firsttickofbar.
    i had to fix it by adding a Update() before the property returned values.
    i notice that none of the indicators provided by NT actually uses this function.
    can someone clarify why Update() makes a difference as i am wondering if i should apply this to all my indicators
    Attached Files

    #2
    Hello junkone,

    Thank you for your post.

    Update() is only needed for certain use cases. In the case of a hosted indicator, like when you use this indicator in a strategy, the indicator needs to be accessed in one of three ways to make sure that OnBarUpdate() functions as expected. The three ways are:
    1. Call Update() on the hosted indicator within the host script
    2. Include a plot in the hosted indicator and access the plot in the host script
    3. Include a plot in the hosted indicator and add the indicator to a chart with AddChartIndicator() (this applies to strategies only)
    This information is explained in the "Notes" section of the OnBarUpdate() page here:For more information regarding Update():Here is a reference sample that exposes an indicator value that is not a plot:
    • https://ninjatrader.com/support/help...alues_that.htm
      • See the ExposedVariable in the SampleBoolSeries.cs indicator script - Update() is called in the Properties region to ensure the exposed variable is up-to-date when accessed in a host script, such as the SampleBoolSeriesStrategy.cs strategy.
    Hopefully this helps to clarify the specific use cases where Update() is needed. Please feel free to reach out with any additional questions or concerns.

    Comment


      #3
      Hi This is what I am looking for, but I need to send data from the strategy to the indicator and I can not get addressability. Tried using a "using strategy name", but get an error, and there is no AddStrategy like there is a AddChartIndicator. Can someone help me here? Thanks. Ken
      from SampleBoolSeries_NT8.zip
      Last edited by kenz987; 03-23-2025, 02:08 PM.

      Comment


        #4
        Hello kenz987,

        There is no supported way to call a strategy from an indicator.

        You can call the indicator from a strategy, and pass information from the strategy to the indicator.

        Below is a link to an example.
        Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you Chelsea, Continuing with the SampleBoolSeries, I would like the Strategy after it gets the signal and opens the trade to send an acknowledgement back to the indicator, (like filled price), and that indicator running on a separate chart without all the strategy lines and clutter. Can that be done? Or should I just spin it out to a txt file and have the other chart read it back in?

          Comment


            #6
            Hello kenz987,

            Yes as long as the strategy is calling the indicator, you can send any information to the indicator you would like.

            This could be text, or a bool, or assigning a series value..

            The example I've provided demonstrates setting a plot series value, but you can set any public variable you would like.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              That is some super programming. Did you grow up as a Microsoft developer? How can I plot on a separate chart? Like chart 1 panel 1 for the price and strategy, and chart 2 panel 1 for the equity curve. If I had a big monitor that went Portrait mode I could do this all in chart 1, but I will need 2 charts for what I want. Any suggestions? (I know I can send it to txt file and read it back in). Thank you for the samples, They are Great.

              Comment


                #8
                Hello kenz987,

                "Did you grow up as a Microsoft developer?"

                :-) No, I've had schooling for computer science and I've been with NinjaTrader for quite a while.

                "How can I plot on a separate chart?"

                Unfortunately, a strategy is not able to host an indicator on another chart.

                Further, an indicator is only able to plot in the panel it is applied to.

                You can call and add multiple indicators to different panels in the same chart.


                Using unsupported code you could push the information to a static class for access from other scripts. Note, our team would not be able to provide assistance with this, but I can provide a simple example.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                563 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                329 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X