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

Protection Level

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

    Protection Level

    I am working on a custom indicator that I thought I had working correctly but when I attempt to call it from a strategy I get the error "inaccessible due to its protection level." I followed the sample at the following link to attempt to make the bool series values public: http://www.ninjatrader-support2.com/...ead.php?t=4991

    The pertinent portions of the indicator code is shown below. The indicator should return a true or false value for the boolseries weakBuy, which it does in the output window.

    Code:
    #region Variables
    private BoolSeries weakBuy;
    #endregion
    
    protected override void Initialize()
    {
    weakBuy = new BoolSeries(this);
    }
    
    In the onBarUpdate section I "set" this boolSeries to either true or false depending on different conditions
    
    [Browsable(false)]
            [XmlIgnore()]
            public BoolSeries WeakBuy
            {
                get
                {
                Update(); 
                return weakBuy;
                }
            }
    In the strategy I am only trying to call the indicator value via a print statement to verify it will call correctly. After this works then I will call in my other code. Am I missing something or what ideas are there to correct this problem?

    Thanks!

    GT

    #2
    Hi GT, please try this without the Update() of weakBuy in the properties section, as weakBuy is already a dataseries class. Thanks!
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thank you for your assistance! I have done this and fixed the way I call the indicator in the strategy. When just the indicator alone is running, the output window show the values changing from true to false but when running the strategy alone that is calling the indicator all it shows is false. In the indicator I have the print statement at the very last line of the onBarUpdate section of code and in the strategy I call it right at the beginning of the onBarUpdate code. In the strategy I use the print format: Print("Time: " + Time[0] + CustomIndicator(14).WeakBuy[0]);

      Is this called correctly? Any other thoughts of things to look at/change?

      Thanks!

      GT

      Comment


        #4
        GT,

        In your indicator be sure to not have any CalculateOnBarClose setting set.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thank you for this tip. I have done this and still works the same as in the last post. Any other thoughts? Also, when/why do you not have any CalculateOnClose setting set? Thanks again!

          GT

          Comment


            #6
            GreenTrade,

            CalculateOnBarClose setting in an indicator when referenced by a strategy is a known bug so you should remove it from all scripts except the parent script.

            As far as for what you are trying. Please upload both files so we can get a better understanding of the interactions between your strategy and your indicator. If you followed the reference sample, it should work as described.

            Please try adding the indicator to the Initialize() method of the strategy to call it there. See if that helps in syncing them up.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Syncing them together did the trick!

              Thanks!

              GT

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cls71, Today, 04:45 AM
              0 responses
              1 view
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              213 views
              1 like
              Last Post PaulMohn  
              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
              4 responses
              544 views
              0 likes
              Last Post PaulMohn  
              Started by GLFX005, Today, 03:23 AM
              0 responses
              3 views
              0 likes
              Last Post GLFX005
              by GLFX005
               
              Started by XXtrader, Yesterday, 11:30 PM
              2 responses
              12 views
              0 likes
              Last Post XXtrader  
              Working...
              X