Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Choppy Market Index

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

    Choppy Market Index

    I am trying to develop a very simple indicator called Choppy Market Index.

    The Choppy Market Index (CMI) is an indicator which compares the difference between the close of the current period with the close X periods ago and normalizes this against the range (highest – lowest) of that period. The value of the indicator is finally multiplied by 100 to give a number between 0 and 100. The formula of the indicator is highlighted below :


    CMI = ((|Close Current period – Close X periods in the past|)/(Highest point in X periods – Lowest point in X periods))*100


    Following is my code for NT but for some reason I am not able to see any line or result. Can someone please tell me what am I doing wrong here?

    protected override void OnBarUpdate()
    {

    Value.Set(((Math.Abs(Close[0]-Close[50]))/(MAX(50)[0]-MIN(50)[0]))*100);
    }

    Thanks

    #2
    Hello,

    You're likely running into an issue explained in the following forum post from our Tips section:





    Please try adding the following snippet to the beginning of your code in OnBarUpdate()
    Code:
    if (Current Bar < 50)
    return;
    You need to ensure you have enough bars on the chart to calculate correctly. This should ensure your Close[50] will calculate.


    It is always good practice to watch the Log tab of the Control Center went developing new indicators to check for any errors.
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

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