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

Inheriting Indicator

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

    Inheriting Indicator

    Hi,

    I am writing a custom indicator which is inherited from an existing Indicator which is compile in a DLL.

    So far my inherited indicator is working as expected. I am trying to add Bollinger Bands but when i do that i receive an error "NinjaTrader.NinjaScript.Indicators.Bollinger is a type but is used like a variable.

    This is my code
    Bollinger _bb = Bollinger(Volume, 1, 20);

    This code works well in my own custom indicator which is inherited from Indicator class, the default way of writing indicators..

    I guess i am missing some reference...

    Does anyone have suggestion?

    Regards,
    Francis

    #2
    Originally posted by francisonweb View Post
    Hi,

    I am writing a custom indicator which is inherited from an existing Indicator which is compile in a DLL.

    So far my inherited indicator is working as expected. I am trying to add Bollinger Bands but when i do that i receive an error "NinjaTrader.NinjaScript.Indicators.Bollinger is a type but is used like a variable.

    This is my code
    Bollinger _bb = Bollinger(Volume, 1, 20);

    This code works well in my own custom indicator which is inherited from Indicator class, the default way of writing indicators..

    I guess i am missing some reference...

    Does anyone have suggestion?

    Regards,
    Francis
    look at post#5

    Comment


      #3
      Hello francisonweb,

      Thank you for your note.

      Without the full code we're unable to test on our end.

      If you'd like to upload the full code I can take a look and see if anything jumps out. Or if you'd prefer to email a copy, send to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread, and the files.

      I look forward to your reply.
      Alan P.NinjaTrader Customer Service

      Comment


        #4
        Hi Alan,

        There is not much code, BetterVolume Indicator is freely available at http://emini-watch.com/free-stuff/volume-indicator/

        This is my code

        public class MyBetterVolume : BetterVolume
        {
        private Bollinger _bb;

        protected override void OnStateChange()
        {
        base.OnStateChange();

        if (State == State.SetDefaults)
        {
        Description = @"MyBetterVolume";
        Name = "MyBetterVolume";
        Calculate = Calculate.OnBarClose;
        IsOverlay = false;
        DisplayInDataBox = true;
        DrawOnPricePanel = true;
        DrawHorizontalGridLines = true;
        DrawVerticalGridLines = true;
        PaintPriceMarkers = true;
        ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
        //Disable this property if your indicator requires custom values that cumulate with each new market data event.
        //See Help Guide for additional information.
        IsSuspendedWhileInactive = true;
        }
        else if (State == State.Configure)
        {
        //_bb = new Bollinger();
        _bb = Bollinger(Volume, 2, 200);
        }
        }

        protected override void OnBarUpdate()
        {
        base.OnBarUpdate();
        //Add your custom indicator logic here.
        }
        }

        Hope this helps you to replicate the issue.

        Regards,
        Francis
        Attached Files
        Last edited by francisonweb; 03-19-2018, 10:16 AM. Reason: Adding image

        Comment


          #5
          Hello francisonweb,

          Without the file which contains the class BetterVolume, I am unable to test on our end.

          What is the advantage of trying to inherit from this BetterVolume class rather than the indicator class?

          I look forward to your reply.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            Hi Alan,

            Thanks for replying the BetterVolume indicator is a DLL file with no source code. It can be downloaded from the link in the previous post.I added the DLL has a reference.

            I am trying to add Bollinger Bands to the indicator so that i can write some notifications and signals.

            Regards,
            Francis

            Comment


              #7
              Hello francisonweb,

              This may be possible however would not be supported.

              If you'd like to create signals off the bollinger study you should create a new indicator instance which inherits from the indicator class.

              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Hi Alan,

                I understand that and i did create a new class everything works but when i add existing indicators like Bollinger or EMA there is compilation error see the error image in my previous post.

                When you say it's not supported means you will not assist for such errors?

                Regards,
                Francis

                Comment


                  #9
                  Hello francisonweb,

                  I have attached a sample indicator which will reference the Bollinger Band study and set the value of its lower band to a plot.

                  You could use this as a framework for adding the Bollinger band to an indicator.

                  Unsupported would apply to having an indicator inherit from your own class rather than the Indicator class, which does not have issue While it may be possible, in the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients.

                  Please let us know if you need further assistance.
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks Alan,

                    I do not see any attachment am i missing something?

                    Regards,
                    Francis

                    Comment


                      #11
                      Hello francisonweb,

                      My apologies.

                      Attached.
                      Attached Files
                      Alan P.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Alan,

                        Thanks for the file, i did try the same but it doesn't work. It may be due to the way the Custom Project is compiled and it is not able to lookup other indicators.

                        Anyways i figured out i am writing the calculation of SMA and StdDev in the indicator file itself and it worked.

                        Thanks again for taking the efforts to look into this :-)

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        3 responses
                        43 views
                        0 likes
                        Last Post jeronymite  
                        Started by frankthearm, Today, 09:08 AM
                        4 responses
                        10 views
                        0 likes
                        Last Post frankthearm  
                        Started by yertle, Today, 08:38 AM
                        5 responses
                        15 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by adeelshahzad, Today, 03:54 AM
                        3 responses
                        18 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by bill2023, Yesterday, 08:51 AM
                        6 responses
                        27 views
                        0 likes
                        Last Post NinjaTrader_Erick  
                        Working...
                        X