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

"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 TraderG23, 12-08-2023, 07:56 AM
    10 responses
    397 views
    1 like
    Last Post beobast
    by beobast
     
    Started by lorem, Yesterday, 09:18 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by WHICKED, Today, 12:56 PM
    2 responses
    15 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Felix Reichert, Today, 02:12 PM
    0 responses
    3 views
    0 likes
    Last Post Felix Reichert  
    Started by Tim-c, Today, 02:10 PM
    0 responses
    5 views
    0 likes
    Last Post Tim-c
    by Tim-c
     
    Working...
    X