• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT 8.0.0.9 Add MTF indicator using AddChartIndicator() fails with Exception

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

    NT 8.0.0.9 Add MTF indicator using AddChartIndicator() fails with Exception

    I`ve uploaded an example of an indicator and strategy.

    Indicator 'AuMTFParablicSAR' calls NT standard indicator ParabolicSAR using 3 multiple timeframes and plots the 3 results.

    The strategy calls indicator 'AuMTFParablicSAR' to retrieve the SAR of 3 different timeframes.

    When I try to use AddChartIndicator() within the OnStateChange() event the strategy fails with this error:
    “Indicator 'AuMTFParablicSAR': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    Strategy 'AuParabolicMOM': Error on calling 'OnStateChange' method: 'AddChartIndicator' cannot be called from this state. Please see the Help Guide article on 'AddChartIndicator' for more information.”
    The indicator and strategy work fine. BUT method AddChartIndicator fails with the object reference exception.

    Can you please explain what else I would need to add to the strategy to get method AddChartIndicator() to work with MTF indicators, or is this an NT8.0.0.9 issue or bug ?

    Thanks
    Attached Files

    #2
    Hello rayko,

    Thanks for your post and test files.

    I will investigate and update this thread when i have further information.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello rayko,

      Thank you for your patience.

      This is due to calling BarsPeriod in the AddDataSeries(). This may work in an indicator but it is not guaranteed. If we call an indicator that uses AddDataSeries() with BarsPeriod in it, it will likely fail in this manner. This has changed a bit from NinjaTrader 7 where the behavior was not guaranteed but in NinjaTrader 8 it is not recommended at all.

      When we dynamically call a BarsPeriod in State.Configure the data may not have loaded yet and thus the BarsPeriod has not information and fails to call.

      To work around this you would need to pass your own variables for the BarsPeriodType and period. So values you could pass through from the strategy to the indicator.

      For the BarsPeriodType I would recommend an enum to select the PeriodType and then use the switch and case in the indicator to determine the call to AddDataSeries().

      If you have any questions please let me know.
      Patrick H.NinjaTrader Customer Service

      Comment


        #4
        Hello Patrick,

        I`ve made the changes you suggested to the MTF indicators and strategies, and method AddChartIndicator is working fine now.

        Thanks

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RtelTrade, Today, 01:27 PM
        0 responses
        2 views
        0 likes
        Last Post RtelTrade  
        Started by NinjaTrader_Brandon, Today, 01:19 PM
        0 responses
        6 views
        0 likes
        Last Post NinjaTrader_Brandon  
        Started by nedstrader, Today, 01:01 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by tvaughan4, Today, 01:02 PM
        0 responses
        9 views
        0 likes
        Last Post tvaughan4  
        Started by RolloHarper, Today, 12:59 PM
        0 responses
        7 views
        0 likes
        Last Post RolloHarper  
        Working...
        X