Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 WHICKED, Today, 12:45 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by samish18, Today, 01:01 PM
    0 responses
    5 views
    0 likes
    Last Post samish18  
    Started by WHICKED, Today, 12:56 PM
    0 responses
    8 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Spiderbird, Today, 12:15 PM
    2 responses
    11 views
    0 likes
    Last Post Spiderbird  
    Started by FrazMann, Today, 11:21 AM
    2 responses
    8 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Working...
    X