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

Show Keltner Band Spread Calculations

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

    Show Keltner Band Spread Calculations

    How can I get an indicator that tells me the distance in points, between the upper Keltner band and the lower Keltner band?
    Keltner Channel indicator

    #2
    Hello Vizard,
    Thanks for your post and welcome to the NinjaTrader forum.

    Are you trying to program this indicator yourself or simply looking for a place to download this indicator?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Thanks for answering
      I'm not a programmer, I'm just looking for a place to download this indicator if it exists with that modification and if not how I could modify it to obtain that additional information to the Keltner Channel.

      Comment


        #4
        Vizard,

        I am not aware of a specific indicator that does this. You may have some luck searching in the User App Share section.



        I can help you modify the existing Keltner Channel indicator to provide that information fairly easily. How would this value be displayed on the chart?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the help.
          I have ended up asking in this section, because I have been searching for it for several days without success on the Internet, in the forum and User Application Section as well.
          I have a capture, as it is in the graphic, I attach it to you.
          It is a panel, like a box, located on the upper left of the graph, what it does is measure the width of the entire channel and shows you at each moment how large the points in the Keltner Channel is, where B.Sp. 10.68 in the image.
          This Keltner indicator in particular is called KeltnerChannelEMA to nijatrader 7
          Attached Files

          Comment


            #6
            Vizard,

            You can open and edit the built in Keltner Indicator by going to your Control Center>>Tools>>Edit NinjaScript>>Indicator...>>select "KeltnerChannel"

            You could add the difference value to the top left by simply adding something similar to the following at the bottom of OnBarUpdate() and the right-clicking to select "compile".

            Code:
            DrawTextFixed("tag", "Difference: "+diff[0], TextPosition.TopLeft);
            As far as the box surrounding it, that is a more advanced concept. I can tell you how to draw a rectangle, but it would be up to you to come up with the appropriate logic to get it drawn around the difference value. Let me know if you are interested in hearing more.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Hello JoshG,
              It would be like this the modification ??, the box I do not care with that it appears the value of the channel in the left would serve to me, comfirmame that is well and I modify it in the indicator.
              Code:
                protected override void OnBarUpdate()
                      DrawTextFixed("tag", "Difference: "+diff[0], TextPosition.TopLeft);    
                      {
                          diff.Set(High[0] - Low[0]);
              
                          double middle    = EMA(Typical, Period)[0];
                          double offset    = EMA(diff, Period)[0] * offsetMultiplier;
              
                          double upper    = middle + offset;
                          double lower    = middle - offset;
              
                          Midline.Set(middle);
                          Upper.Set(upper);
                          Lower.Set(lower);
                      }

              Comment


                #8
                Vizard,

                It would go inside the OnBarUpdate() method. It would be something like this:

                Code:
                protected override void OnBarUpdate()
                {
                         diff.Set(High[0] - Low[0]);
                
                         double middle    = EMA(Typical, Period)[0];
                         double offset    = EMA(diff, Period)[0] * offsetMultiplier;
                
                         double upper    = middle + offset;
                         double lower    = middle - offset;
                
                         Midline.Set(middle);
                         Upper.Set(upper);
                         Lower.Set(lower);
                [B]         DrawTextFixed("tag", "Difference: "+diff[0], TextPosition.TopLeft);    [/B]
                 }
                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  JoshG,
                  I have modified the indicator correctly, a value appears in the upper left, but it is not the correct value that should appear in points, when measuring the width of the channel by hand is greater, I attach capture.
                  Attached Files

                  Comment


                    #10
                    Vizard,

                    You would need to do your own math to get that value. I was able to use the following snippet to calculate that. I suggest putting this where you currently have the DrawTextFixed method

                    Code:
                    double BaseValue    = Bars.Instrument.MasterInstrument.PointValue*TickSize;
                    double numTicks     = diff[0]*TickSize;
                    double final        = numTicks*BaseValue;
                    
                    DrawTextFixed("tag", "Difference: "+final, TextPosition.TopLeft);
                    Josh G.NinjaTrader Customer Service

                    Comment


                      #11
                      I would also like to get the spread for the keltner bands. I have run into an issue after applying the code provided above. Any suggestions? I don't know what any of this means.
                      Attached Files

                      Comment


                        #12
                        SK615, Welcome to the NinjaTrader Forum.

                        The code discussed in this post is for NinjaTrader 7 and will not work for NinjaTrader 8.

                        There are a few key items to look for when converting your scripts from NinjaTrader 7 format to NinjaTrader 8, and we keep a Code Breaking Changes table updated in the NinjaTrader 8 Help Guide to assist in identifying changes or new implementations of familiar methods and properties from NinjaTrader 7: http://ninjatrader.com/support/helpG...ng_changes.htm

                        The names of many methods and properties have changed slightly, so you will need to refactor these in your code. The Code Breaking Changes table can make this task much easier, and there is also an alphabetical reference in the Help Guide that can help to find new method/property names: http://ninjatrader.com/support/helpG..._reference.htm

                        You will want to start by converting all of your NT7 Data Series Objects to Series<t>. Also, the DrawTextFixed() method has been changed as well.

                        I suggest creating another post in the NT8 forum if you would like to discuss this further.

                        Josh G.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bortz, 11-06-2023, 08:04 AM
                        47 responses
                        1,606 views
                        0 likes
                        Last Post aligator  
                        Started by jaybedreamin, Today, 05:56 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        18 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by Jon17, Today, 04:33 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post Jon17
                        by Jon17
                         
                        Started by Javierw.ok, Today, 04:12 PM
                        0 responses
                        13 views
                        0 likes
                        Last Post Javierw.ok  
                        Working...
                        X