Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Keltner Channel with 3 sets of Bands

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

    Keltner Channel with 3 sets of Bands

    I have a custom KC indicator. I would like it to have 3 sets of bands. I've seen other posts where they've had to create 3 indicators to achieve this. Is there another way?

    I'm using the following code to add the basic mid and upper lower bands.

    AddPlot(Brushes.Lime, NinjaTrader.Custom.Resource.KeltnerChannelMidline) ;
    AddPlot(Brushes.Blue, NinjaTrader.Custom.Resource.NinjaScriptIndicator Upper);
    AddPlot(Brushes.Blue, NinjaTrader.Custom.Resource.NinjaScriptIndicator Lower);

    Any ideas would be appreciated.

    Thanks

    #2
    Hi GoldBands, thanks for posting.

    The Bollinger indicator will be the best example to demonstrate this. It can be viewed from the Indicators folder of the NinjaScript editor.

    Kind regards,
    -ChrisL

    Comment


      #3
      Sorry, maybe I wasn't clear. I want a Keltner channel with
      1 mid line
      3 bands above and below the midline.

      The Bollinger Band example you pointed me to has the same 3 lines as the standard Keltner channel. That is not what I want. Here's the BB code:

      AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.BollingerUpperBand);
      AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.BollingerMiddleBand);
      AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.BollingerLowerBand);

      I want

      UpperBand3
      UpperBand2
      UpperBand1
      Midline
      LowerBand1
      LowerBand2
      LowerBand3

      Any help is appreciated.

      Thanks

      Comment


        #4
        Hi, The custom indicator will need to add more plots and set a higher and lower deviation for each plot added. Firstly, right click the Keltner code>Save As>give it a new name to save a copy of this script that can be edited. Then add more plots e.g.:

        Code:
        AddPlot(Brushes.DarkGray, NinjaTrader.Custom.Resource.KeltnerChannelMidline) ;
        AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
        AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
        AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper1);
        AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper2);
        AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower1);
        AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower2);
        Then define more offsets in OnBarUpdate, just for an example, this can be different:

        Code:
        double offset    = smaDiff[0] * OffsetMultiplier;
        double offset1    = smaDiff[0] * OffsetMultiplier*2;
        double offset2   = smaDiff[0] * OffsetMultiplier*4;
        
        double upper1 = middle + offset1;
        double upper2 = middle + offset2;
        double lower1 = middle - offset1;
        double lower2 - middle - offset2;
        
        Values[3][0] = upper1; 
        Values[4][0] = upper2;
        Values[5][0] = lower1;
        Values[6][0] = lower2;

        Comment


          #5
          Hi Chris,

          Thanks for the code. I thought I had actually tried something like that but got compile errors at some point. Now that I know this is the correct approach I will give it another try.

          Thanks,

          Ned

          Comment


            #6
            Hi Chris,

            I am getting an error

            "ninjascript custom resource does not contain a definition for NinjaScriptIndicatorUpper1"

            I am getting it for the 4 bands I want to add.

            How do I add the definition? I am using the script editor, not visual studio.

            Thanks.

            Comment


              #7
              Hi GoldBands, sorry that was my mistake from just pasting the code into the forum. We can use our own String for that parameter:

              Code:
              AddPlot(Brushes.DarkGray, NinjaTrader.Custom.Resource.KeltnerChannelMidline) ;
              AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
              AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
              AddPlot(Brushes.DodgerBlue, "Upper1");
              AddPlot(Brushes.DodgerBlue, "Upper2");
              AddPlot(Brushes.DodgerBlue, "Lower1");
              AddPlot(Brushes.DodgerBlue, "Lower2");

              Comment


                #8
                Thanks, Chris, that worked!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                640 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                366 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                107 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                569 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                572 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X