No announcement yet.

Partner 728x90


Working with user Variables

  • Filter
  • Time
  • Show
Clear All
new posts

    Working with user Variables

    Is there a way to work with formulas from within Strategy Builder to set my User-variables value? Specifically, I want to reset the value after a target was touched, to Zero. That was easy using the Variable = 0 in an Condition / 'action' window. However, If I had a trade which was a loss, I want to add the loss to the variable for that exit and subsequent exits until a profit target was reached, so as to keep a running tab of cumulative loss. I want to use the loss value for subsequent purposes. Is this possible in Strat. Builder or am I off to the wilderness of script editing?

    Hello RedRock,

    Thanks for writing in to our Support Forums!

    There is currently not any functionality to set a variable to another variable (or the same variable) with a mathematical offset. I may submit a feature request for this feature on your behalf, if you'd like.

    Otherwise, you would have to unlock the code and do the scripting manually.

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service



      As manipulating variables is beyond the scope of Strategy Builder, could you possibly point me to some examples where a variable is changed upon some event occurring?

      For example I want to keep track of the number of losing trades before a win is achieved, at which point the variable is reset to zero. Sort of a consecutive real-time loss counter.


        Hello RedRock,

        Thanks for the reply.

        It is within the goal of the Strategy Builder to allow you to build strategies without a programming background. It would benefit yourself as well as others to have the added functionality to do this from the GUI.

        We do not build custom indicators or strategies for customers but if you’d like I could have someone from our business development team pass over a list of professoinal Ninja Script consultants that you could contact about developing this for you. If this is the case please write in to platformsupport[at]ninjatrader[dot]com with the text "1678176 ATTN Jim" in the subject of the email.

        The NinjaTrader 7 help guide contains basic programming concepts that teach you about variables and other basic programming syntax.

        You can view the programming resources from NinjaTrader 7's help guide here:
        Basic Syntax -
        Programming Concepts -
        NinjaScript Editor 401 -

        After you have looked into working with variables, and are comfortable with your knowledge of C# you may wish to look at the reference sample on protective orders so you can write your strategy to keep track of your trades in OnOrderUpdate() and OnExectution(). These overrides are for advanced programmers so I advise to start small with your programming endeavors.

        That sample can be found here:

        I'm still willing to submit the feature request for the Strategy Builder to have better variable handling. Please let me know if you would like me to submit a request for it.
        JimNinjaTrader Customer Service


          Sure Jim, Please submit the request... Great idea which should be helpful to many!

          I have been programming in another more 'natural language' environment for some time. So I know that Ill need to get a grasp on C# to make full use of NT8. Ill look at your samples and see if I can get my brain to 'click'.

          Thanks, RR


            Hello RedRock,

            Thanks for your input to help improve NinjaTrader.

            The feature request is being tracked with ticket ID SFT-2059 and can be seen in the Release Notes of the version of NinjaTrader 8 that contains the feature request's implementation. You can use the link below to view the Release Notes page of the help guide.


            You may also writing in to platformsupport[at]ninjatrader[dot]com to ask a technician on the status of the ticket ID.

            Please let me know if you have any questions.
            JimNinjaTrader Customer Service


            Latest Posts


            Topics Statistics Last Post
            Started by robforee2, Today, 01:05 PM
            1 response
            Last Post NinjaTrader_Jesse  
            Started by SpikeLGWG, Today, 12:35 PM
            1 response
            Last Post NinjaTrader_Jim  
            Started by Kaalhus, Today, 12:47 PM
            2 responses
            Last Post Kaalhus
            by Kaalhus
            Started by Johnny, Today, 11:55 AM
            3 responses
            Last Post NinjaTrader_Spencer  
            Started by MGHORBEL, Today, 10:48 AM
            0 responses
            Last Post MGHORBEL