Announcement

Collapse
No announcement yet.

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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by abelsheila, 05-14-2025, 07:38 PM
        2 responses
        32 views
        0 likes
        Last Post hglover945  
        Started by nailz420, 05-14-2025, 09:14 AM
        1 response
        66 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
        0 responses
        336 views
        1 like
        Last Post NinjaTrader_Brett  
        Started by domjabs, 05-12-2025, 01:55 PM
        2 responses
        64 views
        0 likes
        Last Post domjabs
        by domjabs
         
        Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
        1 response
        83 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X