Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 Issues with Declaration of Variables

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

    NT8 Issues with Declaration of Variables

    I am trapping bad data in a multi-time frame Indicator using 10 Tick, 50 Tick, 1 Minute & 5 Minute time frames.
    I am trying to save the current value as LastEASlope.
    But every time the data goes negative I get an error message as seen in the attachment.

    I have tried every combination of things I can think of and still can’t find a solution.
    While using the “New Indicator Builder” I have tried:
    Type: double
    Minimum = 0
    Minimum = -100
    Minimum = NULL
    All had the same response- it doesn’t like negative numbers


    Code Samples

    if (State == State.SetDefaults)
    EASlope = 0;
    LastEASlope = 0;


    #region Properties
    [NinjaScriptProperty]
    [Display(Name="EASlope", Order=7, GroupName="Parameters")]
    Public double EASlope
    { get; set; }

    [NinjaScriptProperty]
    [Display(Name="LastEASlope", Order=8, GroupName="Parameters")]
    public double LastEASlope
    { get; set; }





    Code

    var BadData = false; //Error Checking (this is the Primary Series)
    if(EASlopeSeries[0] >= 0)
    LastEASlope = EASlopeSeries[0];
    else if(EASlopeSeries[0] < 0)
    LastEASlope = EASlopeSeries[0];
    else
    {
    EASlopeSeries[0] = LastEASlope;
    BadData = true;
    }



    Please help me with a viable solution.

    Chris Knudsen
    Attached Files

    #2
    Hello CKnudsen,
    Thanks for your post.

    One thing you could potentially do is not let that variable be set to a negative number. Maybe assign it a zero instead, when it would otherwise be negative. I modified your snippet to show you what I mean:
    Code:
    if(EASlopeSeries[0] >= 0)
    	LastEASlope = EASlopeSeries[0];
    else if(EASlopeSeries[0] < 0)
    [B]	LastEASlope = 0;[/B]
    I will leave this post open for any other members that would like to provide advice or other solutions.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Thank you... I'll try it, but why doesn't NT8 like the negative numbers? What am I doing wrong?

      Comment


        #4
        I think that is an error with C# and not necessarily a NinjaScript limitation. It could be your public property as well. Maybe try switching it out with something that defines the range like this.

        Code:
        [NinjaScriptProperty]
        [Range(-100, double.MaxValue)]
        [Display(Name="LastEASlope", Order=8, GroupName="Parameters")]
        public double LastEASlope
        { get; set; }
        Josh G.NinjaTrader Customer Service

        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
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X