Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Choppiness Index

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

    Choppiness Index

    Hello Support,
    I need help with changing color of the line to green when the Choppiness Index is below 62.8 and sloping down(falling). I am creating a strategy on Strategy Builder.
    NinjaTrader 8

    #2
    Hello pickles1774,

    Thank you for your post.

    Please see my reply here about copying the ADX and applying logic to change the color of the plot:
    Hello Support, Could you show me how to change the line color of the NT8 ADX indicator to change to green when it is above 20 and is sloping up(rising). Ineed to use in strategy builder NinjaTrader 8 (https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?average_directional_index_adx.htm)​


    The same concept could be applied to create a copy of the Choppiness Index indicator and add logic that modifies the colors of the plot when desired.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Emily,
      i dont have coding expereince. I dont know where I would place the logic into the code: So what i need is the line color to change to green when it is below 62.8 and slope is falling. Red color when it is equal or above 62.8.
      CAUTION: This is an email from an external source. Do not click links or open attachments unless you recognize the sender and know the content is safe.
      //
      // Copyright (C) 2023, NinjaTrader LLC <www.ninjatrader.com>.
      // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
      //
      region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion

      // This namespace holds indicators in this folder and is required. Do not change it.
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class ChoppinessIndex : Indicator
      {
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionChoppinessIndex;
      Name = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNa meChoppinessIndex;
      IsOverlay = false;
      Period = 14;

      AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNa meChoppinessIndex);
      AddLine(Brushes.DarkCyan, 38.2, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer);
      AddLine(Brushes.DarkCyan, 62.8, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUp per);
      }
      }

      protected override void OnBarUpdate()
      {
      Value[0] = (MAX(High, Period)[0] - MIN(Low, Period)[0]).ApproxCompare(0) == 0 || SUM(ATR(1), Period)[0].ApproxCompare(0) == 0 ? 0 : 100 * Math.Log10(SUM(ATR(1), Period)[0] / (MAX(High, Period)[0] - MIN(Low, Period)[0])) / Math.Log10(Period);
      }

      region Properties
      [Range(2, int.MaxValue), NinjaScriptProperty]
      [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)]
      public int Period
      { get; set; }
      #endregion
      }
      }

      region NinjaScript generated code. Neither change nor remove.

      namespace NinjaTrader.NinjaScript.Indicators
      {
      public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
      {
      private ChoppinessIndex[] cacheChoppinessIndex;
      public ChoppinessIndex ChoppinessIndex(int period)
      {
      return ChoppinessIndex(Input, period);
      }

      public ChoppinessIndex ChoppinessIndex(ISeries<double> input, int period)
      {
      if (cacheChoppinessIndex != null)
      for (int idx = 0; idx < cacheChoppinessIndex.Length; idx++)
      if (cacheChoppinessIndex[idx] != null && cacheChoppinessIndex[idx].Period == period && cacheChoppinessIndex[idx].EqualsInput(input))
      return cacheChoppinessIndex[idx];
      return CacheIndicator<ChoppinessIndex>(new ChoppinessIndex(){ Period = period }, input, ref cacheChoppinessIndex);
      }
      }
      }

      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
      {
      public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
      {
      public Indicators.ChoppinessIndex ChoppinessIndex(int period)
      {
      return indicator.ChoppinessIndex(Input, period);
      }

      public Indicators.ChoppinessIndex ChoppinessIndex(ISeries<double> input , int period)
      {
      return indicator.ChoppinessIndex(input, period);
      }
      }
      }

      namespace NinjaTrader.NinjaScript.Strategies
      {
      public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
      {
      public Indicators.ChoppinessIndex ChoppinessIndex(int period)
      {
      return indicator.ChoppinessIndex(Input, period);
      }

      public Indicators.ChoppinessIndex ChoppinessIndex(ISeries<double> input , int period)
      {
      return indicator.ChoppinessIndex(input, period);
      }
      }
      }

      #endregion

      Last edited by pickles1774; 04-02-2024, 09:03 AM.

      Comment


        #4
        Hello pickles1774,

        Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services or one-on-one educational support in our NinjaScript Support department. This is so that we can maintain a high level of service for all of our clients as well as our associates. This thread will remain open in case any members of the forum community would like to assist you with this script.

        That said, through email or on the forum we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. We are also happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior. For example, I have shared the link to the multi-colored plots sample with you:


        When certain conditions are met, that examples changes the PlotBrushes color for the desired plot:


        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team to follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one-on-one educational services.

        Thank you for using NinjaTrader.​

        Comment


          #5
          Thats strange because I see support providing codes on this forum. If I create a code and i get an error when I compile, could you tell me why I got the error and how to fix it. Because i see lots of similar post to mines where support is providing solutions, So I dent understand why my question is different from the others.

          Comment


            #6
            Originally posted by pickles1774 View Post
            Thats strange because I see support providing codes on this forum. If I create a code and i get an error when I compile, could you tell me why I got the error and how to fix it. Because i see lots of similar post to mines where support is providing solutions, So I dent understand why my question is different from the others.
            Yes; you could attempt to code this yourself and if you get any errors or unexpected behavior we would be glad to assist you with the steps through the debugging process. Please take a look at this example that changes the colors of plots and read the code comments (the lines that start with //) to get a better understanding of which parts of the code are changing the colors and what conditions are changing the colors:


            You can try adding in your desired behavior incrementally. For more information on getting started with NinjaScript:


            Please let us know if we may be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            602 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            347 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
            559 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            558 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X