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

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 junkone, Today, 11:37 AM
            0 responses
            4 views
            0 likes
            Last Post junkone
            by junkone
             
            Started by quantismo, 04-17-2024, 05:13 PM
            5 responses
            34 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by proptrade13, Today, 11:06 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            34 views
            0 likes
            Last Post love2code2trade  
            Started by cls71, Today, 04:45 AM
            2 responses
            10 views
            0 likes
            Last Post eDanny
            by eDanny
             
            Working...
            X