Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss and SetProfitTarget example

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

    SetStopLoss and SetProfitTarget example

    Hello,

    Is there sample code available that elegantly handles partial fills when an order is created, and properly assigns the stop and profit targets? I am continually running into issues, e.g: stop or profit triggers on a long position, but additional orders are sent to go short; or the stop and target don't get placed at all. These issues only happen on a live feed.

    Thanks!

    #2
    Hello shadowfax,

    Thanks for your post.

    I would expect the Set methods to properly protect a position even in the event of a partial fill.

    Do you see the issue with the attached script? This script will enter a long position after enabling the strategy for the quantity specified. If you see an issue here, what instrument are you trading on and who is your broker? Is the trade submitted to the live account or with the Sim101 account? Please also ensure you are updated to the latest version of the platform before testing further.

    Update - https://ninjatrader.com/PlatformDirect

    If you do not see an issue testing this script, could you modify the example so it models what you are doing with the Set methods? The modification should not be your personal trading signal logic but should demonstrate how the issue can be encountered. We could then provide additional insight or investigate further if an issue is spotted on the platform's end.

    Note that when using Set methods outside of State.Configure/State.DataLoaded, these methods should be used when the strategy is flat and before the entry is submitted. (Set methods prep NinjaTrader to submit targets/stops when the strategy sees that the entry order has filled.) An example demonstrating best practices for using Set methods dynamically can be found below.

    SamplePriceModification - https://ninjatrader.com/support/help...of_stop_lo.htm

    Outside of set methods, our SampleOnOrderUpdate strategy has some logic for protecting partially filled entries.



    I look forward to hearing back.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    32 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    195 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    358 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    277 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X