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

Workaround for using IsValidDataPoint() on guest indicators with MaxBarsLookBack256

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

    Workaround for using IsValidDataPoint() on guest indicators with MaxBarsLookBack256

    Hi guys,
    I'm hoping someone can provide a workaround for using .IsValidDataPoint() on guest indicators that have MaximumBarsLookBack256 set internally. My hosting indicator has the ability to call any guest indicator (with a Plot() of Series<>). The issue is some guest indicators have MaximumBarsLookBack set to 256, and as the documentation states IsValidDataPoint() can't be used with those indicators.
    1. What is your suggested workaround for this?
    2. Can MaximumBarsLookBack be overwritten for a guest indicator?
    3. Can the state of MaximumBarsLookBack be checked on a guest indicator?
    Thanks.
    zacwhitesi
    NinjaTrader Ecosystem Vendor - Shark Indicators

    #2
    Hello zacwhitesi,

    You can set the MaximumBarsLookBack from the variable holding the instance of the indicator.

    Attached is an example that demonstrates (by printing to the output window).
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      I have a follow up for a similar matter. Can the IsSuspendedWhileInactive property be read from an object holding the 'Input series' as an indicator?
      e.g.
      inputIndy = Input as Indicator;
      IsSuspendedWhileInactive = inputIndy.IsSuspendedWhileInactive;


      The only property I can find is .IsSuspended, but that seems like the real-time state of the Input/guest indicator. I want to set the host indicator in OnStateChange().

      Thanks
      Last edited by zacwhitesi; 01-29-2019, 03:30 PM.
      zacwhitesi
      NinjaTrader Ecosystem Vendor - Shark Indicators

      Comment


        #4
        Hello zacwhitesi,

        Unfortunately, this property cannot be set from a host script.

        From the help guide:
        The IsSuspendedWhileInactive property will be ignored and real-time events will be processed as normal under the following cases:
        • Indicators running in Automated NinjaScript Strategies
        https://ninjatrader.com/support/help...leinactive.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks for confirming. In my case its an indicator hosting a guest indicator via the Input series. I'd like the host indi to adapt the needs of the guest indi, if .IsSuspendedWhileInactive is explicitly set, so that CPU processing can be minimized when possible.
          I'd like to add this as a request. As more powerful indicators are being built it would be good idea to extend .IsSuspendedWhileInactive 's abilities, so Add-ons have the ability to minimize their impact on the platform.
          zacwhitesi
          NinjaTrader Ecosystem Vendor - Shark Indicators

          Comment


            #6
            Hello zacwhitesi,

            From my understanding if the indicator is not applied directly to the chart then it will be using the value from the host indicator. (This is why you can't set this from a strategy as a strategy needs it to always be false)

            Are you finding this is not the case from testing?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              (This is why you can't set this from a strategy as a strategy needs it to always be false)
              Are you finding this is not the case from testing?
              I'm not working with a strategy. As I said, "In my case its an indicator hosting a guest indicator..." I'm only concerned with a hosting indicator.
              For strategies that makes a lot of sense, but indicators don't have the same requirement.

              Again, I'd like to add this as a request, so good programmers can help minimize performance impact on the platform. This would be a Read-Only of the .IsSuspendedWhileInactive property.
              Last edited by zacwhitesi; 01-30-2019, 01:13 PM.
              zacwhitesi
              NinjaTrader Ecosystem Vendor - Shark Indicators

              Comment


                #8
                Hello zacwhitesi,

                I've further clarified with our development.

                Regardless of how IsSuspendedWhileInactive is set in the code of a hosted script, NinjaTrader will override that specifically when the script is hosted either by another indicator or a strategy. The IsSuspendedWhileInactive will match the setting of the host script. If the calling indicator has IsSuspendedWhileInactive as false, the hosted script as its being called from the host script will also be called with IsSuspendedWhileInactive as false and will continue updating when the chart or chart tab is not in view.

                That said, NinjaTrader is doing further suspension activity, again regardless of the setting of IsSuspendedWhileInactive in the hosted script.
                If indicator is not called in OnBarUpdate the indicator is automatically suspended in the background and stops processing incoming ticks. If its called on a later bar, it catches up using end of bar data, the same as how an indicator added to a chart behaves when exiting suspension on a chart.

                This means as long as the indicator is designed to always be called on every bar update, the IsSuspendedWhileInactive of the hosted script will match the host script (even if the value is set to an empty variable as a placeholder).
                If the indicator is not called on every bar, the indicator will be automatically suspended for the bars it is not called.

                I will submit a feature request on your behalf for the NinjaTrader Development to consider allowing the IsSuspendedWhileInactive to be set from a host script and for this to prevent the automatic suspension when not called from a host script. Once I have a tracking ID for this request I will forward this to you for future reference.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello zacwhitesi,

                  I have received tracking ID# SFT-3803 for this request to explicitly set IsSuspendedWhileInactive for hosted scripts.

                  Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.

                  We appreciate your request on this.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Regardless of how IsSuspendedWhileInactive is set in the code of a hosted script, NinjaTrader will override that specifically when the script is hosted either by another indicator or a strategy. The IsSuspendedWhileInactive will match the setting of the host script. If the calling indicator has IsSuspendedWhileInactive as false, the hosted script as its being called from the host script will also be called with IsSuspendedWhileInactive as false and will continue updating when the chart or chart tab is not in view.
                    Thanks, this i understood from the documentation. It would probably be good to add this extra info to the documentation for others.

                    Originally posted by NinjaTrader_ChelseaB View Post
                    That said, NinjaTrader is doing further suspension activity, again regardless of the setting of IsSuspendedWhileInactive in the hosted script.
                    If indicator is not called in OnBarUpdate the indicator is automatically suspended in the background and stops processing incoming ticks. If its called on a later bar, it catches up using end of bar data, the same as how an indicator added to a chart behaves when exiting suspension on a chart.

                    This means as long as the indicator is designed to always be called on every bar update, the IsSuspendedWhileInactive of the hosted script will match the host script (even if the value is set to an empty variable as a placeholder).
                    If the indicator is not called on every bar, the indicator will be automatically suspended for the bars it is not called.
                    Thanks again for this extra level of info. This to would be good to add to the documentation.

                    Originally posted by NinjaTrader_ChelseaB View Post
                    I will submit a feature request on your behalf for the NinjaTrader Development to consider allowing the IsSuspendedWhileInactive to be set from a host script and for this to prevent the automatic suspension when not called from a host script. Once I have a tracking ID for this request I will forward this to you for future reference.
                    Just to be clear. I'd like the host indi to be able to read the IsSuspendedWhileInactive setting of a guest indi, before the guest indi inherits the host indi's IsSuspendedWhileInactive setting. Effectively, this would allow the host indi to adopt/inherit the guest indi setting. Which would allow the host indi to minimize CPU processing if the guest indi allows itself to be suspended.
                    zacwhitesi
                    NinjaTrader Ecosystem Vendor - Shark Indicators

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by judysamnt7, 03-13-2023, 09:11 AM
                    4 responses
                    57 views
                    0 likes
                    Last Post DynamicTest  
                    Started by ScottWalsh, Today, 06:52 PM
                    4 responses
                    36 views
                    0 likes
                    Last Post ScottWalsh  
                    Started by olisav57, Today, 07:39 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post olisav57  
                    Started by trilliantrader, Today, 03:01 PM
                    2 responses
                    19 views
                    0 likes
                    Last Post helpwanted  
                    Started by cre8able, Today, 07:24 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post cre8able  
                    Working...
                    X