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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    174 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    329 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    252 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    356 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    183 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X