Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopLoss settings . . .

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

    StopLoss settings . . .

    So my question is that within my strategy I am adjusting the StopLoss as the trade progresses.

    I do set the StopLoss in State.DataLoaded using the code SetStopLoss("", CalculationMode.Ticks, iStopLoss, false); where
    iStopLoss is an Integer set within the Strategy.

    My question is if I go into a trade and set the StopLoss programmatically at a price (e.g. 100) and that trade closes. On my next
    trade where is the StopLoss set? Is it in the State.DataLoaded, or does it default back to the last price set? If I have set the StopLoss
    programatically do, I then need to set the StopLoss before I submit a trade?

    Thanks for the assistance.

    #2
    Hello ATMtrader0001,

    Thanks for your post.

    The help guide on SetStopLoss() (and all of the other set methods) specifies that the method should be set up in State.Configure. Please see the help guide link here: https://ninjatrader.com/support/help...etstoploss.htm Typically you would set this in State.Configure if you are going to use the same set method value on all entries, for example always using a 20 tick stop loss or always using a 25 tick profit target on every order. This approach lessens the programming effort but fixes the values of your trades.

    In your case you want to use it dynamically as you may have conditions that would cause a trade to be set differently, you do not need to configure it State.Configure (or any other state), what you do need to though is set it before you place your entry order as this will ensure that when the entry order is filled it will automatically have the correct value for the set method (this applies to all set methods when used dynamically). here is a simple example:

    if (your entry conditions)
    {
    SetStopLoss(.....); //set the stop value before entry
    SetProfitTarget(....); // set the target value before entry
    EnterLong();
    }


    To answer your question, yes the set methods will retain the last value applied and will apply those on the next entry order fill.

    Note that you can also mix the set method calculation modes, In the above example perhaps at the moment you do not know precisely where to place the stop/target so you would use CalculationMode.Ticks and set them initially for the order at some known distance from the average entry price, then later perhaps you have logic that establishes different or evolving set values to use and in that case you can use CalculationMode.Price if you want to specify it in price terms.

    Comment


      #3
      Thanks. I think that setting it via Ticks prior to order entry is the way to go. I was setting it to the last Close plus or minus # of ticks, but the results weren't always as expected.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      116 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      61 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      40 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      43 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      82 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X