Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy settings drop down list for loss limit

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

    Strategy settings drop down list for loss limit

    I'd like to add an unrealized loss limit currency value to the strategy settings page. I want to be able to specify the max amount before it exits positions by typing it in the strategy settings window.

    This is the piece of code I would use

    // Condition set 1
    if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) < 1000)
    {
    ExitLong("", "L1");
    }
    {
    ExitShort("", "S1");
    }

    #2
    Hello brucelevy,

    Thank you for your inquiry.

    In order to allow for a user defined parameter in your strategy, you would need to create a property for that particular parameter.

    Here is an example:
    Code:
    #region Variables
    private int loss = 1000; // default value of 1000
    #endregion
    
    ....
    
    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int Loss
    {
          get { return loss; }
          set { loss = Math.Max(1, value); }
    }
    #endregion
    You would then utilize the "loss" variable rather than the hard-coded 1000.

    If utilizing the Strategy Wizard, you would be able to do this by defining a User Defined Input. So, rather than using the hard coded value of 1000 in the sample you have provided, you can select the user defined input instead.

    User Defined Inputs are defined on the page right before the Conditions and Actions page of the Strategy Wizard.

    Attached to this post is how the Condition Builder would look for the condition you have specified. My user defined input is called "Loss".

    Please, let us know if we may be of further assistance.
    Attached Files
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    50 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X