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

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.

    Paul H.NinjaTrader Customer Service

    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 frankthearm, Today, 09:08 AM
      5 responses
      14 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      43 views
      0 likes
      Last Post jeronymite  
      Started by yertle, Today, 08:38 AM
      5 responses
      15 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by adeelshahzad, Today, 03:54 AM
      3 responses
      19 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by bill2023, Yesterday, 08:51 AM
      6 responses
      27 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X