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

Moving from a SetStopLoss to SetTrailStop

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

    Moving from a SetStopLoss to SetTrailStop

    Hello NT Support,

    I'm developing a strategy that is looking to catch large intraday moves. When entering a trade, I have a SetStopLoss at a reasonable level and a goal price with SetProfitTarget (typically, many points away). After the trade moves enough in my favor, I would like cancel the SetStopLoss and then use SetTrailStop so that some profits are locked in but still allow the trade to "breathe" to make larger profit moves.

    I'm not seeing any means to do this. The CancelOrder routine needs an order but the SetStopLoss routine doesn't return any Order object.

    If I'm understanding correctly and am able to cancel the SetStopLoss order, I would need to do the following:
    1. Cancel SetStopLoss order
      1. NOTE: Because of the OCO connection, the SetTargetPrice order is automatically cancelled, too.
    2. Call SetTrailStop AND call SetTargetPrice at the same level I had before.
    I'm using these method calls, so I'm connecting the order with the fromEntrySignal.
    SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool isSimulatedStop)
    SetProfitTarget(string fromEntrySignal, CalculationMode mode, double value, bool isMIT)


    Is this possible?

    Thanks!
    Matt

    #2
    Hello StealthM93,

    The Set method orders cannot be cancelled, you would need to use the other order methods like ExitLongStopMarket so you have an order object that can be used with CancelOrder.

    Alternatively you would just not cancel the order and add logic in OnBarUpdate to call SetStopLoss to update its price, you can create a trailing stop with SetStopLoss by calling it each time you want to change its price.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello NinjaTrader_Jesse,

      Thank you for the quick response. I'm aware that I could code a trailing stop and update SetStopLoss as appropriate, but I'm looking to avoid coding that logic. However, I didn't think about using Exit_StopMarket order instead of SetStopLoss. I'll look at that.

      Thanks!
      Matt

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by LiamTwine, Today, 08:10 AM
      0 responses
      2 views
      0 likes
      Last Post LiamTwine  
      Started by Balage0922, Today, 07:38 AM
      0 responses
      5 views
      0 likes
      Last Post Balage0922  
      Started by JoMoon2024, Today, 06:56 AM
      0 responses
      6 views
      0 likes
      Last Post JoMoon2024  
      Started by Haiasi, 04-25-2024, 06:53 PM
      2 responses
      19 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      6 views
      0 likes
      Last Post Creamers  
      Working...
      X