Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set a stop loss

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

    How to set a stop loss

    I create an order like this in a method:

    ExitShortStopMarket(0,
    true,
    OrderQuantity,
    adjustedStopPrice,
    signalName,
    order.FromEntrySignal);​

    In the OnOrderUpdate() method, I check for the fill status and attempt to create a stop loss order.

    The code below executes, but no stop loss ever shows up. The order object is passed into the OnOrderUpdate() method as a parameter.

    ExitShortStopMarket(0,
    true,
    OrderQuantity,
    adjustedStopPrice,
    signalName,
    order.FromEntrySignal);

    What am I missing?​

    #2
    Hello sultanofsuede,

    Thank you for your post.

    I recommend taking a look at this example script which demonstrates using OnOrderUpdate and OnExecutionUpdate to submit protective orders, compare this to your own script to see where the issue may be occurring:



    Please let us know if you need further guidance.

    Comment


      #3
      Hi thx for the reply!

      I found the docs for OnExecutionUpdate and moved the logic for stop loss/target profit creation to there. My stuff works now.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X