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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      61 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X