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

bool variable keeps changing

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

    bool variable keeps changing

    So i have a bool variable called, "EnableLong". It's set as true under State.SetDefaults. i havent had any issues with it until today. For some reason, it keeps changing to False when i run my custom strategy. I've commented out all instances of "EnableLong = false;" Yet it still changes to false. Is that even possible?

    #2
    Hello only_nq,

    Welcome to the NinjaTrader forums!

    If it's been set to false at any time it will remain false.
    State.SetDefaults runs for the new instance of the script and never again.
    If you want to reset this to true each time you run the script, set this to true in State.DataLoaded, which runs each time the script is enabled.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thanks for the suggestion. It turns out, i had a statement: "else if (EnableLong = true .... " with one equal sign, and compile didnt catch that? So i guess that's where EnableLong was changed to false. i thought that's not possible inside if else structure...

      Comment


        #4
        Hello only_nq,

        Assignments can be done in branching commands. One equal sign will always be an assignment, two equal signs will always be a comparison.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pibrew, Today, 06:37 AM
        0 responses
        1 view
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        11 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        15 views
        0 likes
        Last Post AaronKoRn  
        Working...
        X