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

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 frslvr, 04-11-2024, 07:26 AM
    9 responses
    120 views
    1 like
    Last Post caryc123  
    Started by rocketman7, Today, 09:41 AM
    4 responses
    15 views
    0 likes
    Last Post rocketman7  
    Started by selu72, Today, 02:01 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by WHICKED, Today, 02:02 PM
    2 responses
    14 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by f.saeidi, Today, 12:14 PM
    8 responses
    21 views
    0 likes
    Last Post f.saeidi  
    Working...
    X