Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddChartIndicator(RegressionChannel(200,3));

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

    AddChartIndicator(RegressionChannel(200,3));

    I use AddChartIndicator and am unclear on how to do so with the regression channel.

    Any examples

    #2
    Hello BartMan,

    Thanks for your post.

    You could use the Strategy Builder to create a condition using the RegressionChannel indicator with the 'Plot on chart' setting checked and then click the 'View code' button to see the generated syntax for how this is done.

    The code might look something like this:

    //class level variable
    private Indicators.RegressionChannel RegressionChannel1;

    //OnStateChange
    else if (State == State.DataLoaded)
    {
    RegressionChannel1 = RegressionChannel(Close, 200, 3);
    RegressionChannel1.Plots[0].Brush = Brushes.DarkGray;
    RegressionChannel1.Plots[1].Brush = Brushes.DodgerBlue;
    RegressionChannel1.Plots[2].Brush = Brushes.DodgerBlue;
    AddChartIndicator(RegressionChannel1);
    }


    See the help guide documentation below for more information.

    RegressionChannel(): https://ninjatrader.com/support/help...ionchannel.htm
    AddChartIndicator(): https://ninjatrader.com/support/help...tindicator.htm
    Adding Indicators to Strategies: https://ninjatrader.com/support/help..._strategie.htm
    Creating Indicator to Value Conditions in Strategy Builder: https://ninjatrader.com/support/help...arisons​
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks, but that still does not work I get ==> RegressionChannelB1.cs,The name 'AddChartIndicator' does not exist in the current context,CS0103,60,5,

      I believe it is a name conflict as @RegressionChannel.cs exist as a drawing tool and as an indicator.

      Code attached

      Attached Files

      Comment


        #4
        Hello BartMan,

        Thanks for your notes.

        I see that the script you shared is an indicator.

        The AddChartIndicator() method can only be used in a custom NinjaScript strategy, not a custom NinjaScript indicator.

        You would have to add three plots to your script for each plot the RegressionChannel indicator has and then assign the RegressionChannel indicator plot values (Middle, Upper, Lower) to each plot you added to the script.

        See the help guide documentation below for more information and sample code.

        AddPlot(): https://ninjatrader.com/support/help...t8/addplot.htm
        RegressionChannel(): https://ninjatrader.com/support/help...on_channel.htm
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thx I use addoncode and run against indicators, no strategies involved. I have created my own custom data series. I thought I had added addchart to indicators before, but it was in strategies I wrote for a colleague. The addon gives more control.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          368 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          571 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X