Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Flag" Ability in Code

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

    "Flag" Ability in Code

    Hello. I am fairly new to NT and this forum.

    I am a programmer and am trying to figure out how to set a "global" flag in my code that does not get updated on every bar. For instance, I am writing code to scale out of a position and I want to set a "flag" once my first target is hit so that I can use an if statement to check for my bool "flag" setting and if it is true (1st target has been hit); I will ignore this exit and the code will continue to check my next exit logic.

    In my mind I need to declare this variable outside of the OnBarUpdate section but when I try to do this I get compilation errors (i.e. OnStartUp).

    I hope this all makes sense; can someone help me please? I have searched the NT help guide and all over this forum and I can't find anything related to what I'm trying to do. Any ideas?

    Thanks.

    #2
    Hello Brirob14,

    Thank you for your post and welcome to the Forums!

    If you are looking to get the fill of the order then I would suggest tracking that in either OnOrderUpdate() or OnExecution so that you can then get the fill and change your flag the way you need to.

    OnExecution()
    OnOrderUpdate()
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    618 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    561 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    566 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X