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

CCI Negatove number issue

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

    CCI Negatove number issue

    HI I am writing a strategy and when i specified negative numbers in properties, it still doesnt allow me to get enabled, its complaining that Period is not valid number 1-999999. I am making a logic if close [0] and price is above CCIButtomLine -> long

    private CCI CCITop;
    private CCI CCIButtom;
    private CCI CCIPeriod;

    region CCI Indicator settings
    CCITopLine = 100;
    CCIButtomLine = -80;
    CCIPeriodUsed = 7;
    #endregion​

    CCITop = CCI(Close,(CCITopLine));
    CCIButtom = CCI(Close,(CCIButtomLine));
    CCIPeriod = CCI(Close,(CCIPeriodUsed));

    region Properties
    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="CCI100TopLine", Order=1, GroupName="Parameters")]
    public int CCITopLine
    { get; set; }

    [NinjaScriptProperty]
    [Range(-100, double.MaxValue)]
    [Display(Name="CCI100ButtomLine", Order=2, GroupName="Parameters")]
    public int CCIButtomLine
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="CCIPeriod", Order=3, GroupName="Parameters")]
    public int CCIPeriodUsed
    { get; set; }

    [NinjaScriptProperty]
    [Display(Name="Use CCI", Order=0, GroupName="Parameters")]
    public bool UseCCI
    { get; set; }
    #endregion​​
    Attached Files
    Last edited by tkaboris; 02-05-2023, 10:56 AM.

    #2
    Hello tkaboris,

    Thanks for your post.

    This error indicates that you are using a Period value for your CCI() method that is outside of the acceptable range.

    The CCI() method is only able to use a Period parameter of 1 or greater. Negative values cannot be used for the CCI() method's Period parameter.

    For example, the CCI() method might look something like this where we use a value of 20 for the Period parameter.

    CCI(Close, 20)[0]

    The line of code to compare if the current CCI value is greater than -80 would look something like this.

    if (CCI(Close, 20)[0] > -80)
    {
    //do something here
    }


    See this help guide page for more information: https://ninjatrader.com/support/help..._index_cci.htm

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for response. IN my logic long i have
      && (CCI(Close,CCIPeriodUsed)[0] > -CCIButtomLine) but I still get the error when trying to enable strategy.

      I dont understand i specify for Period a positive number though

      CCI has a top line and bottom line, +100 and -100. I need to use those levels

      region CCI Indicator settings
      CCITopLine = 100;
      CCIButtomLine = -80;
      CCIPeriodUsed = 7;
      #endregion​
      Attached Files
      Last edited by tkaboris; 02-05-2023, 09:12 PM.

      Comment


        #4
        Hello tkaboris,

        Thanks for your note.

        To understand why the script is behaving as it is, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        Add prints outside of each condition that uses CCI() that prints out each value being used for the Period parameter of CCI() to see how each value is evaluating. Prints will appear in a New > NinjaScript Output window.

        Once you determine which CCI() method is using a negative value for the Period parameter, you could modify the method to use a positive value of 1 or greater.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.

        https://ninjatrader.com/support/foru...121#post791121

        Please let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by WHICKED, 06-27-2023, 12:07 PM
        84 responses
        867 views
        1 like
        Last Post WHICKED
        by WHICKED
         
        Started by sofortune, 06-13-2024, 02:31 AM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by GodAtum, Today, 09:52 AM
        11 responses
        25 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by TheTechnician86, Yesterday, 10:44 PM
        2 responses
        13 views
        0 likes
        Last Post TheTechnician86  
        Started by flonkle, Today, 01:19 AM
        4 responses
        29 views
        0 likes
        Last Post flonkle
        by flonkle
         
        Working...
        X