Announcement

Collapse
No announcement yet.

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