Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Basing one Property/Parameter on Another Property/Parameter

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

    Basing one Property/Parameter on Another Property/Parameter

    I am trying to modifiy the set{} statement for one parameter so the parameter can only be less than another parameter. A problem occurs when set is called for RSILengthLong; it is getting the prior value of rSILengthLong and not the value just entered. If I enter the value a second time, it works. I think I understand why this happens, but cannot figure out code that will allow it to function correctly the first time I enter a new value. The code I'm using is:

    PHP Code:
    [Description("Momentum Length (Long) - Value between 5 and 50")]
    [GridCategory("\t\t\tEntry")]
    [Gui.Design.DisplayName("\t\t\t\tMomentum Length (Long)")]
    public int MOMLengthLong
    {
      get { return mOMLengthLong; }
      set { mOMLengthLong = Math.Min(Math.Max(5,value),50); }
    }
     
    [Description("RSI Length (Long) - Value between 2 and 50")]
    [GridCategory("\t\t\tEntry")]
    [Gui.Design.DisplayName("\t\t\t\tRSI Length (Long)")]
    public int RSILengthLong
    {
      get
      {
         int returnValue = 0;
         if (rSILengthLong > MOMLengthLong)
          {
            returnValue = MOMLengthLong;
          }
        else
        {
          returnValue = rSILengthLong; 
        }
        return returnValue;
      }
      set
      {
        Print(rSILengthLong+" "+MOMLengthLong);
        if (rSILengthLong >= MOMLengthLong)
        {
          rSILengthLong = MOMLengthLong-1;
        }
        else
        {
          rSILengthLong = Math.Min(Math.Max(2,value),50);
        }
      }
    } 
    
    If anyone has a suggestion, it will be greatly appreciated.

    Thanks,
    Greg
    The Trading Mantis
    NinjaTrader Ecosystem Vendor - The Trading Mantis

    #2
    Greg, this probably has to do with the variable you are accessing. When making a variable public (editable), there are actually two variables, the private variable (with lowercase starting letter) and the public variable (capitalized starting letter). Please try comparing the public variables and see if that does the trick.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Hi Austin, I tried using the public variable RSILengthLong, but I get a recursion error.
      The Trading Mantis
      NinjaTrader Ecosystem Vendor - The Trading Mantis

      Comment


        #4
        Greg, I just checked with a co-worker and this actually isn't possible. You can run the check in OnStartUp() and modify the variable on the fly to the value you want. If you are using NT6.5, OnStartUp() doesn't exist, but you run it in this little block of code:
        Code:
        OnBarUpdate()
        {
            if (CurrentBar == 0) // indicating the very start of the indicator run
            {
                // change your variables
            }
        }
        AustinNinjaTrader Customer Service

        Comment


          #5
          Try
          [RefreshProperites(RefreshProperties.All)]

          On the first property

          Baruch

          Comment


            #6
            Baruch, Does that work in NT7? I added the lines but get an error that the namespace RefreshProperites does not exist.

            Austin, that will work as a fallback.

            Thanks guys!
            The Trading Mantis
            NinjaTrader Ecosystem Vendor - The Trading Mantis

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            580 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            335 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            102 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X