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

Property always return false

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

    Property always return false

    Good morning,

    I add a property to my strategy but it always return false even if I write "return true"

    Code:
    [FONT=Courier New][SIZE=2]
    [SIZE=2][FONT=Courier New][Browsable([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])] [/SIZE][/FONT]
    [SIZE=2][FONT=Courier New][XmlIgnore()][/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] IsRising[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]    get[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]return [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]; }[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT]
    Any idea why?

    Regards,
    Steven
    Last edited by SMuhr; 08-27-2010, 05:09 AM.

    #2
    You have hardcoded it with this snippet, try for example something like this -

    Code:
     
    [Description("My Bool")]
    [GridCategory("Parameters")]
    publicbool MySwitch
    {
    get { return mySwitch; }
    set { mySwitch = value; }
    }
    In your variables:

    Code:
    private bool mySwitch = true;
    This will then start with a true default if the indicator is loaded.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      In fact, it should no be a parameter.
      Just a property form the strategy class.

      I hardcoded it to true to see if the property isRising return true.
      But it does not

      Comment


        #4
        How would you eactly access it then to determine it's false?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          In my code it is like this :

          Code:
          private bool isRising = false;
           
          //Some code set isRising to true & sometimes to false
           
          [FONT=Courier New][Browsable([SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][SIZE=2])] [/SIZE]
          [SIZE=2][XmlIgnore()][/SIZE]
          [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][SIZE=2] IsRising[/SIZE]
          [SIZE=2]{[/SIZE]
          [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]    get[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] { [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return [/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]isRising[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New][SIZE=2]; }[/SIZE]
          [SIZE=2]}[/SIZE]
          [/FONT][/SIZE]
          But it always return false.
          Si I hardoced the return value of IsRising to true but it still return false

          thx
          Last edited by SMuhr; 08-27-2010, 06:48 AM.

          Comment


            #6
            SMuhr, in your last example you set isRising to false and then the public property IsRising to this value, so for sure it returns false then - are you sure the code attempting to change it is triggering at all?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              the value isRising is set to True during the call of the method OnBarUpdated().
              Evenf if I hardcoded the property IsRising to return true and acces it trougth the getter, I get False. (I have check with Visual Studio and breakpoint)

              Comment


                #8
                Ok, thanks for testing in VS - can you please attach the script(s) you used so I can look into here?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Unfortunatly I cannot.
                  I wil find a work arround thanks Bertrabd

                  Comment


                    #10
                    Ok - if you look for historical data for this, you would need to expose a BoolSeries like shown here - http://www.ninjatrader.com/support/f...ead.php?t=4991

                    Hopefullly this helps you getting in the right direction.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rdtdale, Today, 01:02 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post rdtdale
                    by rdtdale
                     
                    Started by alifarahani, Today, 09:40 AM
                    3 responses
                    15 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by RookieTrader, Today, 09:37 AM
                    4 responses
                    18 views
                    0 likes
                    Last Post RookieTrader  
                    Started by PaulMohn, Today, 12:36 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post PaulMohn  
                    Started by love2code2trade, 04-17-2024, 01:45 PM
                    4 responses
                    40 views
                    0 likes
                    Last Post love2code2trade  
                    Working...
                    X