Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Manually modify strategy-generated orders

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

    Manually modify strategy-generated orders

    I currently have a strategy that submits a stop loss and a profit target when a stop limit entry order is filled, but I'm unable to move these orders around. What I would like to do is have the ability to move these orders up and down with a DOM or ChartTrader but whenever I do that now, they snap right back to their original price. Is there any way to accomplish what I'm looking for?

    Thanks - Brandon

    #2
    Hello Brandon,

    Thanks for your post.

    The SetStopLoss(), SetProfitTarget() and SetTrailStop() methods will all use internal rules that will update the stop or target to the assigned level after each bar closure.

    It is possible to use the Exit methods to serve as your profit target and stop loss with the isLiveUntilCancelled overload so the orders can then be adjusted manually.

    I've attached some sample code demonstrating how this is possible:
    Code:
    protected override void OnBarUpdate()
    {
    if(Historical)
    return;
    if(Position.MarketPosition == MarketPosition.Flat)
    EnterLong("MyEntry");
    }
    
    protected override void OnExecution(IExecution execution)
    {
    if(execution.Name == "MyEntry")
    ExitLongStop(0, true, 1, Position.AvgPrice - 10 * TickSize, "MyExit", "MyEntry");
    }
    Publicly available documentation on the methods used can be referenced below.

    OnExecution() - https://ninjatrader.com/support/help...nexecution.htm

    ExitLongStop() (Please see isLiveUntilCancelled overload) - https://ninjatrader.com/support/help...itlongstop.htm

    Also, for a more robust approach to using Exit methods for your protective orders as well as the OnOrderUpdate() and OnExecution() methods, I recommend reviewing the SampleOnOrderUpdate example.

    SampleOnOrderUpdate - https://ninjatrader.com/support/foru...ead.php?t=7499

    Please let us know if you have any additional questions.
    Last edited by NinjaTrader_ChelseaB; 10-14-2022, 08:02 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X