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

SetStopLoss adjustment

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

    SetStopLoss adjustment

    I want to start my trade with a stop loss and then adjust the StopLoss value as my trade proceeds. This is similar to trailing stop, but then with StopLoss value that is dynamically calculated.
    I am using the following command to adjust my short stop at the end of each M1 bar when conditions are met: SetStopLoss(Convert.ToString(TradeCount),Calculati onMode.Ticks,ShortStopPrice,false);

    The ShortStopPrice is calculated correctly, but for some reason my StopLoss is not triggered when the price on the short trade rises through the ShortStopPrice.

    Can you help me understand what I am doing wrong?

    #2
    Hello PaulZ,

    Currently, you have the CalculationMode set to CalculationMode.Ticks (as in a number of ticks from the entry price) but it looks like you are supplying a price.

    I think you may want to be using CalculationMode.Price if you want to set this to an exact price.

    You can always start with a number of ticks and then change to a price.

    When the stop loss is placed, at what price is this being placed? (This can be found in the Orders tab of the Control Center when the order is placed live, or in the Strategy Performance window from right-clicking the chart, on the Orders tab)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I changed to CalculationMode.Price as you suggested.
      The order Tab only shows the Stop Loss that I originaly placed but not a change in the Stop Loss that I hoped to set with the command that I described before.
      Am I right in thinking that SetStopLoss overrides a previous Stop Loss? Or do I need to cancel my old Stop Loss first. If so, how do I do that?

      Comment


        #4
        Hello PaulZ,

        Yes, as long as the stop loss uses the same or no fromEntrySignal, it will update the existing stop loss.

        So if you called SetStopLoss(CalculationMode.Ticks, 10) before placing the entry order, the stop will be placed 10 ticks from the entry. Then if you call SetStopLoss(CalculationMode.Price, 2000), the existing working stop loss will be moved to 2000 on the price scale.

        Below is a link to an example I've made that shows how to move a stop loss.
        https://ninjatrader.com/support/foru...193#post410193
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        18 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        9 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        10 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X