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

Request - HMA and Bollinger Bands In Single Indicator

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

    Request - HMA and Bollinger Bands In Single Indicator

    Hi,

    Can anyone help me with or guide me develop HMA and Bollinger Bands in a single indicator?

    Thanks in advance.

    #2
    psb1967, this could certainly be done in a custom indicator - however both parts are already present per default in NT, so you could just save them togehter as a chart template and then be ready to quickly apply them as needed.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      psb1967, this could certainly be done in a custom indicator - however both parts are already present per default in NT, so you could just save them togehter as a chart template and then be ready to quickly apply them as needed.
      Hello Bertrand,

      Thats exactly how I have done and am using at present. Nevertheless, I would prefer them in a single indicator, if possible.

      Comment


        #4
        You're welcome, I see - not sure how familiar you are with programming in our NinjaScript but those tutorials would be a great start - http://www.ninjatrader.com/support/h.../tutorials.htm

        To start, simply create yourself a 'raw' indicator within the indicator wizard, offering for example 4 Plots in total (1 for the HMA, 3 for the default Bollinger Bands including the midline). For instance name them Plot0, Plot1, Plot2 and Plot3.

        Next fill them with your needed indicator values in the OnBarUpdate() section of the code :

        Code:
        Plot0.Set(HMA(Close, 20)[0]);
        Plot1.Set(Bollinger(Close, 2, 20).Upper[0]);
        Plot2.Set(Bollinger(Close, 2, 20).Lower[0]);
        Plot3.Set(Bollinger(Close, 2, 20).Middle[0]);
        Once done press F5 to compile the new study.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          DONE it!!!!

          Originally posted by NinjaTrader_Bertrand View Post
          You're welcome, I see - not sure how familiar you are with programming in our NinjaScript but those tutorials would be a great start - http://www.ninjatrader.com/support/h.../tutorials.htm

          To start, simply create yourself a 'raw' indicator within the indicator wizard, offering for example 4 Plots in total (1 for the HMA, 3 for the default Bollinger Bands including the midline). For instance name them Plot0, Plot1, Plot2 and Plot3.

          Next fill them with your needed indicator values in the OnBarUpdate() section of the code :

          Code:
          Plot0.Set(HMA(Close, 20)[0]);
          Plot1.Set(Bollinger(Close, 2, 20).Upper[0]);
          Plot2.Set(Bollinger(Close, 2, 20).Lower[0]);
          Plot3.Set(Bollinger(Close, 2, 20).Middle[0]);
          Once done press F5 to compile the new study.
          Hello Bertrand,

          Thanks a million. Done it. It works.

          Only a minor issue. In our default Bollinger bands indicator, I can set my std. dev. below 1- i.e. in decimals. But in my new indicator I am not able to change it to below 1; have to do it in the script. Did I commit any mistake?

          My script:

          #region Variables
          // Wizard generated variables
          private double numStdDev = 0.26; // Default setting for NumStdDev
          private int period = 14; // Default setting for Period
          private int pperiod = 21; // Default setting for Pperiod
          // User defined variables (add any user defined variables below)
          #endregion

          /// <summary>
          /// This method is used to configure the indicator and is called once before any bar data is loaded.
          /// </summary>
          protected override void Initialize()
          {
          Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "Plot0"));
          Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot1"));
          Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot2"));
          Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot3"));
          Add(new Line(Color.FromKnownColor(KnownColor.Blue), 26, "HMA"));
          Add(new Line(Color.FromKnownColor(KnownColor.Orange), 14, "Upper"));
          Add(new Line(Color.FromKnownColor(KnownColor.Orange), 14, "Middle"));
          Add(new Line(Color.FromKnownColor(KnownColor.Orange), 14, "Lower"));
          Overlay = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.
          Plot0.Set(HMA(Close,21)[0]);
          Plot1.Set(Bollinger(Close,0.26,14).Upper[0]);
          Plot2.Set(Bollinger(Close,0.26,14).Lower[0]);
          Plot3.Set(Bollinger(Close,0.26,14).Middle[0]);
          }

          Comment


            #6
            Nice work, congrats - please check into the properties section of the script - you will see something like the below -

            Code:
            public double NumStdDev
            {
            	get { return numStdDev; }
            	set { numStdDev = Math.Max(1.0, value); }
            }
            Change this for example to -

            Code:
            public double NumStdDev
            {
            	get { return numStdDev; }
            	set { numStdDev = Math.Max(0.01, value); }
            }
            This will effectively tell your public property (the user input) to accept values down to 0.01 as well for the double defining your StdDev.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Nice work, congrats - please check into the properties section of the script - you will see something like the below -

              Code:
              public double NumStdDev
              {
                  get { return numStdDev; }
                  set { numStdDev = Math.Max(1.0, value); }
              }
              Change this for example to -

              Code:
              public double NumStdDev
              {
                  get { return numStdDev; }
                  set { numStdDev = Math.Max(0.01, value); }
              }
              This will effectively tell your public property (the user input) to accept values down to 0.01 as well for the double defining your StdDev.
              Hello Bertrand,

              Changed as advised. Now in my user input, I am able to change the std.dev. below 1 but still its plotting on the chart 1. My actual std.dev. is 0.26 and 14.

              I also changed in the script the std.dev. to default to 2.

              public double NumStdDev
              {
              get { return numStdDev; }
              set { numStdDev = Math.Max(0.01, value); }
              }

              Comment


                #8
                Sorry, missed that part earlier for you - try this instead please:

                Plot0.Set(HMA(Close, Pperiod)[0]);
                Plot1.Set(Bollinger(Close,NumStdDev, Period).Upper[0]);
                Plot2.Set(Bollinger(Close,NumStdDev, Period).Lower[0]);
                Plot3.Set(Bollinger(Close,NumStdDev, Period).Middle[0]);
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  Sorry, missed that part earlier for you - try this instead please:

                  Plot0.Set(HMA(Close, Pperiod)[0]);
                  Plot1.Set(Bollinger(Close,NumStdDev, Period).Upper[0]);
                  Plot2.Set(Bollinger(Close,NumStdDev, Period).Lower[0]);
                  Plot3.Set(Bollinger(Close,NumStdDev, Period).Middle[0]);
                  Hello Bertrand,

                  Quite long ago, you helped me develop my first MA Crossover indicator with up and down arrows.

                  Yes, the above code worked.

                  Thanks a million again for your immense patience and guidance.

                  Nice day.
                  Attached Files
                  Last edited by psb1967; 07-13-2012, 06:08 AM.

                  Comment


                    #10
                    Need to add RSI

                    Hello Bertrand,

                    I need one more guidance from you. I want to add RSI in my HMA-BB Indicator. Please bear with me for the trouble.

                    Thanks again in advance.

                    Comment


                      #11
                      Ignore RSI request

                      Hello Bertrand,

                      Please ignore my RSI request. Thanks.

                      Nice weekend.

                      Comment


                        #12
                        Glad you found a solution for you, have a good weekend.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Bertrand View Post
                          Glad you found a solution for you, have a good weekend.
                          Hello Bertrand,

                          Thanks for your reply.

                          Although I am not a fan of auto strategy, I ventured into developing my first HMA-BB-RSI Strategy and it so happened it ended up if not exactly, almost the way I trade manually. Only I could not find a way to plot the text, Buy/Sell or arrows on the chart but managed with bar coloring respectively.

                          My conditions are: Price should Close above HMA & BB; 2. RSI should be above 50 for long and vice versa for short.

                          Humbly putting it, the credit goes to you for, I got full inspiration like last time with my MA crossover indicator, from you and you know how to make a novice like me who knows nothing about coding to come out with the desired results.

                          Yet another constraint I have to put up with, I have become used to having Haiken Ashi but now have to do away with it due to bar coloring.

                          Thanks again and pleasant weekend to you.
                          Last edited by psb1967; 07-28-2012, 10:07 AM.

                          Comment


                            #14
                            Originally posted by psb1967 View Post
                            Hi,

                            Can anyone help me with or guide me develop HMA and Bollinger Bands in a single indicator?

                            Thanks in advance.
                            If you want to calculate the Bollinger Bands by using the HMA, this can be done as well. The Bollinger Universal indicator can calculate the Bollinger Bands from a Median or 27 different moving aveages.

                            The best futures trading community on the planet: futures trading, market news, trading charts, trading platforms, trading strategies


                            Harry

                            Comment


                              #15
                              Originally posted by Harry View Post
                              If you want to calculate the Bollinger Bands by using the HMA, this can be done as well. The Bollinger Universal indicator can calculate the Bollinger Bands from a Median or 27 different moving aveages.

                              The best futures trading community on the planet: futures trading, market news, trading charts, trading platforms, trading strategies


                              Harry
                              Hello Harry,

                              Thanks for the suggestion. I know about Bollinger Universal but I don't calculate Bollinger bands using other MAs except with the default one.

                              Good day.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DavidHP, Today, 07:56 AM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by kujista, Today, 06:23 AM
                              3 responses
                              9 views
                              0 likes
                              Last Post kujista
                              by kujista
                               
                              Started by Mindset, Yesterday, 02:04 AM
                              2 responses
                              18 views
                              0 likes
                              Last Post NinjaTrader_RyanS  
                              Started by f.saeidi, Today, 08:03 AM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by samish18, 04-17-2024, 08:57 AM
                              15 responses
                              54 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X