Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit trade with stop loss

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

    Exit trade with stop loss

    Hi,
    I enter a short trade with:
    Code:
    EnterShort(0, 1, "SHORT");
    I would like to create a StopLoss for this trade with known price level. Every bar I would like to update the level of the Stop Loss Price. I want to execute immediately the Stop Order.
    What is the best way?

    1. Right after I execute EnterShort, I can run:
    Code:
    SetStopLoss("SHORT", CalculationMode.Price, StopLossPrice, false);
    or
    2. At the
    Code:
    BarsInProgress == 1
    which is 1 tick I can run
    Code:
    ExitShort(0, 1, "SL", "SHORT");
    or something else?

    I noticed that when I use the 2nd option, the order is not done asap and there are several ticks done in the middle - there are 4-5s until the ExitShort order is completed. I use Rithmic.

    #2
    Hello iskier,

    Thanks for your post.

    To modify the price of a SetStopLoss() order you would need to dynamically call this method in OnBarUpdate().

    Here is a reference sample demonstrating modifying the price of a stop loss order: https://ninjatrader.com/support/help...of_stop_lo.htm

    From the SetStopLoss() help guide:

    "You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position

    Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position"


    SetStopLoss(): https://ninjatrader.com/support/help...etstoploss.htm

    Note that ExitShort() would not place a stop loss order, this would be a market order to exit a short position.

    If you want to use Exit methods, you could consider using ExitShortStopMarket() in OnExecutionUpdate() to place a stop loss order.

    Here is a reference sample demonstrating this concept: https://ninjatrader.com/support/help...and_onexec.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      thanks for reply.
      I use the SetStopLoss() on OnBarUpdate().

      That would be difference in using SetStopLoss and using ExitShortStopMarket()?
      In the DOM, the SetStopLoss other participants on the market will the pending order and with the ExitShortStopMarket() it will a market order?
      Which do you recommend?

      Comment


        #4
        Hello iskier,

        Thanks for your notes.

        It would be up to you to choose which method you would like to use for submitting the stop loss order from your script.

        SetStopLoss() will submit a stop market order.

        ExitShortStopMarket() would submit a stop market order.

        See the help guide documentation below for more information about these methods and how they function.

        SetStopLoss(): https://ninjatrader.com/support/help...etstoploss.htm
        ExitShortStopMarket(): https://ninjatrader.com/support/helpGuides/nt8/exitshortstopmarket.htm​

        See this help guide page for more information about order types: https://ninjatrader.com/support/help...rder_types.htm
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        56 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        132 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X