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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      164 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      85 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      126 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      207 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      185 views
      0 likes
      Last Post CarlTrading  
      Working...
      X