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

Turn Off/On SetStopLoss

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

    Turn Off/On SetStopLoss

    I've seen some other posts related, but they don't quite answer my question.

    I'm using SetStopLoss and I want to enter different values with each new entry. I use CalculationMode.Price and that works fine.

    But how would I properly turn off the stop so that a new entry would not have an associated stop?

    The answer it seems is to set the price far enough away that the stop won't get executed. But how far is that? Ideally, as far away as possible to ensure we don't get caught up in any price shocks.

    What I've found is that I can set the stop price to one tick and everything works fine in backtest. I wonder though if that will work in live trading?

    Would it be better to use something like SetStopLoss(CalculationMode.Currency, 100000)? My testing shows that a value of 100000 will disable the stop loss entirely for the duration of the strategy, but a value of 10000 will not.

    Similarly, I've noticed that if I call SetStopLoss(CalculationMode.Pice, 0) that the stop loss remains disabled for the duration of the strategy. Even if I set price back to a higher value, the stop will not take effect. Is this the expected behavior?

    Could you clarify the size/price limits, why they exist and perhaps suggest the recommended approach?

    Thanks





    #2
    Hello BarzTrading,

    Thanks for your post.

    Through testing, setting a very large value for the StopLoss for Currency that would place the stop below a price level of 0, the stop loss submission will be ignored. You will see the following in your Log tab:

    12/21/2018 8:45:50 AM Default Strategy 'MyCustomStrategy4/156526107': Calculated stop order price was smaller/equal 0. No stop order placed.
    I generally would recommend using the Exit methods instead of using the Set methods for your logic, since the Set methods prep NinjaTrader to submit the Profit Target and Stop Loss once the next associated entry gets filled. Using your own Exit methods will also give you more explicit control of your stops.

    However, if you follow the recommended approach to reset the Stop and Target when the strategy is flat before the next entry, you should be able to set a stop loss that will be ignored on the next submission. I did not see any issue testing this advised approach on my end. An example that demonstrates the recommended way to reset Stops and Targets when the strategy is flat is linked below.

    SamplePriceModification - https://ninjatrader.com/support/help...of_stop_lo.htm

    I will also note that resetting the stop to a currency value of 0 will cause the strategy to submit an order at the market price and would not be recommended.

    Please let me know if I can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks, Jim.

      In the example you link to, the "reset" looks like this:
      Code:
      if (Position.MarketPosition == MarketPosition.Flat)
      {
           SetStopLoss(CalculationMode.Ticks, StopLossTicks);
      }
      I don't understand how this is "resetting" the stoploss. It's just changing the price, right? I don't see how this means the stoploss would be ignored. You'd still have an order on wouldn't you? But in this case at the price associated with StopLossTicks.

      Just trying to get some clarity before I consider switching over to using Exit methods.

      If I do switch to using Exit methods, can you clarify for me if an ExitLongStopMarket order would be automatically canceled when the position is closed by some other means? Or do I still need to manually ensure those orders get canceled when the position is closed.

      Does NT automatically cancel exit orders when there is no longer a corresponding open position?

      Thanks

      Comment


        #4
        Hello BarzTrading,

        SetStopLoss is set to a new level when the position is flat and before the next entry is submitted. When the next submitted entry fills, the new stop loss level will be used.

        If you place the stop loss below a price of 0, the stop loss submission will be ignored.

        The help guide example provided does not use CalculationMode.Currency. Setting a high Currency value that puts the stop loss below 0 will have the stop loss submission ignored.

        Exit methods are tied together via SignalNames and internal management that assured that the strategy is still in a position to keep the order active. I would recommend testing a simple strategy that enters a position and places an ExitLongLimit and an ExitLongStopMarket order when the position is Long to observe the cancellation when one of these orders fills. This is handled on the platform side and does not use native OCO.

        Further reference on using the Managed Approach and the rules involved can be found here - https://ninjatrader.com/support/help...d_approach.htm

        Please let me know if you have any questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks, Jim.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Conceptzx, 10-11-2022, 06:38 AM
          2 responses
          53 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by Kaledus, Today, 01:29 PM
          0 responses
          3 views
          0 likes
          Last Post Kaledus
          by Kaledus
           
          Started by PaulMohn, Today, 12:36 PM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by yertle, Yesterday, 08:38 AM
          8 responses
          37 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by rdtdale, Today, 01:02 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X