Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

custom vertical bars on CCI charts

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

    custom vertical bars on CCI charts

    how can i paint vertical bars in ninjatrader cci chart like i can do in amibroker?
    here is NT chart and amibroker side by side.


    #2
    Hello junkone,

    If you are referring to setting a plot to the bar style (or histogram style) in code (development), this would be done with PlotStyle.Bar overload parameter.
    AddPlot(Stroke stroke, PlotStyle plotStyle, string name)


    If you are asking how to draw a vertical line, this is done with Draw.VerticalLine().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ok, i am trying this but it does not work
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = "CustomCCI";
      Name = "CustomCCI";
      IsSuspendedWhileInactive = true;
      Period = 100;

      AddPlot(Brushes.Goldenrod, PlotStyle.Bar, "custom cci");// i get error on this line
      AddLine(Brushes.DarkGray, 200, NinjaTrader.Custom.Resource.CCILevel2);
      AddLine(Brushes.DarkGray, 100, NinjaTrader.Custom.Resource.CCILevel1);
      AddLine(Brushes.Yellow, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZe roLine);
      AddLine(Brushes.DarkGray, -100, NinjaTrader.Custom.Resource.CCILevelMinus1);
      AddLine(Brushes.DarkGray, -200, NinjaTrader.Custom.Resource.CCILevelMinus2);
      }
      else if (State == State.DataLoaded)
      sma = SMA(Typical, Period);
      }

      Comment


        #4
        Hello junkone,

        To use the PlotStyle parameter, you will need to use the overload signature with a stroke.

        AddPlot(Stroke stroke, PlotStyle plotStyle, string name)

        There are no overload signatures with (Brush, PlotStyle, string) in the help guide that I linked.

        The Brush can be supplied to the new stroke object.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          perfect. how do I color the histo green if its above 0 and orange if its below 0?


          public class CustomCCI : Indicator
          {
          private SMA sma;

          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = "CustomCCI";
          Name = "CustomCCI";
          IsSuspendedWhileInactive = true;
          Period = 100;

          AddPlot(new Stroke(Brushes.Goldenrod), PlotStyle.Bar, "custom cci");
          AddLine(Brushes.DarkGray, 200, NinjaTrader.Custom.Resource.CCILevel2);
          AddLine(Brushes.DarkGray, 100, NinjaTrader.Custom.Resource.CCILevel1);
          AddLine(Brushes.Yellow, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZe roLine);
          AddLine(Brushes.DarkGray, -100, NinjaTrader.Custom.Resource.CCILevelMinus1);
          AddLine(Brushes.DarkGray, -200, NinjaTrader.Custom.Resource.CCILevelMinus2);
          }
          else if (State == State.DataLoaded)
          sma = SMA(Typical, Period);
          }

          protected override void OnBarUpdate()
          {
          if (CurrentBar == 0)
          Value[0] = 0;
          else
          {
          double mean = 0;
          double sma0 = sma[0];

          for (int idx = Math.Min(CurrentBar, Period - 1); idx >= 0; idx--)
          mean += Math.Abs(Typical[idx] - sma0);

          Value[0] = (Typical[0] - sma0) / (mean.ApproxCompare(0) == 0 ? 1 : (0.015 * (mean / Math.Min(Period, CurrentBar + 1))));
          }
          }

          Comment


            #6
            Hello junkone,

            Set the PlotBrushes[plot index][bar index].
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            599 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            344 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            558 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            557 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X