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.

      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 Barry Milan, Yesterday, 10:35 PM
        5 responses
        16 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        12 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by terofs, Today, 04:18 PM
        0 responses
        11 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by nandhumca, Today, 03:41 PM
        0 responses
        8 views
        0 likes
        Last Post nandhumca  
        Working...
        X