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

Object Ref error using indicator with embedded indicators in a strategy

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

    #16
    Additional interesting info

    I've added some more debugging code and see that parameters I input that are used to set periods for the embedded Indicators are not being passed or received by the embedded indicators.

    These parameters are used in the onStartUp event of my custom indicator. Moving them to the OnBarUpdate improves things.
    daqu40
    NinjaTrader Ecosystem Vendor - QTradez

    Comment


      #17
      Originally posted by daqu40 View Post
      I've added some more debugging code and see that parameters I input that are used to set periods for the embedded Indicators are not being passed or received by the embedded indicators.

      These parameters are used in the onStartUp event of my custom indicator. Moving them to the OnBarUpdate improves things.
      Hello daqu40,

      I am glad to hear it sounds like we are making progress. It looks like what may be happening, is the TickSize parameter is not yet set up before we try to use it. I am including an excerpt from the help guide,

      Originally posted by http://ninjatrader.com/support/helpGuides/nt7/ticksize.htm
      NOTE: This property should NOT be accessed within the Initialize() method.
      It is possible that the code in your Plot method is being accessed from Initialize, or from a nearby point in execution time.

      A safe alternative would be to set up a private variable, MyTickSize, give this an initial value such as 0 or -1 which you can check to see if it is initialized, and to then initialize this value in OnBarUpdate.

      Please let us know if there are any other ways we can help.
      Jessica P.NinjaTrader Customer Service

      Comment


        #18
        Doubtful the Plot is being accessed from Initialize. I don't call any methods that interact with the Chart.

        I did find a statement that was at the root of many problems:

        RCPeriod = (int)(RCPeriod * TrendStrength / 10);

        For some reason, RCPeriod would lose its value and become 1 in OnBarUpdate when this indicator was used in a strategy.

        To fix this I created a DefaultRCPeriod and this seemed to get allow RCPeriod to keep its value when the indicator is being used in my strategy.

        I'd still like to get these indicators to work by referencing a variable rather than the fully qualified call to the indicator, but for now, I need to move forward and will come make the code look clean once the strategy is working.

        Thanks for everyone's help on this.
        daqu40
        NinjaTrader Ecosystem Vendor - QTradez

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        36 views
        0 likes
        Last Post love2code2trade  
        Started by alifarahani, Today, 09:40 AM
        2 responses
        13 views
        0 likes
        Last Post alifarahani  
        Started by junkone, Today, 11:37 AM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by pickmyonlineclass, Today, 12:23 PM
        0 responses
        1 view
        0 likes
        Last Post pickmyonlineclass  
        Started by frankthearm, Yesterday, 09:08 AM
        12 responses
        44 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X