Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how and where to insert a user input variable in NinjaScript editor

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

    how and where to insert a user input variable in NinjaScript editor

    I have a script that was created in Strategy Builder.

    The Strategy builder explicitly asks for the name, the type, the default value, the minimum value.
    but in the NinjaScript section where those user inputs are declared, it's just a simple line that says:

    VariableName = 4; (where 4 is the default value in strategy Builder, and the type integer was chosen)

    I opened my strategy in NinjaScript editor, edited it extensively, - it compiles. I like it and want to add user input criteria to the strategy.
    I can't open it in Strategy Builder anymore.
    How do I add user input variables to the script.?

    I tried inserting the variable name and default value in the section at the top of the script where the other input variables are defined,
    giving it a name, and assigning an integer as a default value followed by a semicolon on an inserted line.
    using the same format as other user input integers declared in this section, ex:

    ========trimmed content==========
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    NewsAt730 = false; <----created in strategy builder
    NewsAt845 = false;​ <----created in strategy builder
    Variable8CreatedinStrategyBuilder = 4; <----created in strategy builder
    MyNewInsertedVariableHere = 2; <-----new variable line was inserted here.
    Variable9CreatedinStrategyBuilder = 6; <----created in strategy builder
    }
    else if (State == State.Configure)
    {
    ========trimmed content==========​

    When I try to compile the editor says the name "MyNewInsertedVariableHere" does not exist in this context.

    I can see that I somehow added other user input variables to this section of the script (or at least changed their names or positions), and they compile and appear as options on the screen where I enable the strategy on a chart.

    I tried using a new strategy builder to create a user input variable, opened its script and copied that line into my script. - Same error.

    Have I forgotten a step?

    What is the standard protocol for declaring a new user input variable in the Ninjascript editor?
    Thanks.

    #2
    Hello Berry Trader,

    Thank you for your post.

    Make sure you are adding code in the Properties section for each new parameter your create.

    Please see the Help Guide page on creating user defined input parameters which demonstrates:
    https://ninjatrader.com/support/help...d_input_pa.htm

    If you have any further questions, please let me know.

    Comment


      #3
      Thanks, Gaby. I found the property section by scrolling to the bottom of the ninjascript editor.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X