Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

set stop loss orders not working consistently.

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

    #16
    Hello rtwave.

    Set methods do not specify a BarsInProgress index, but they would use the data series they are called on and the data series the entry order is called on. In a multi time frame script, mixing these between data series can be messy, and if we want to have consistency with order fills, we should then be sure to direct all of our orders using Exit methods to the same data series. (In my example we submit to BarsInProgress == 1, which is a single tick data series for most granularity.)

    In summary, you can use Set methods in a multi time frame script, but it gets messy if you are mixing enter/exit logic between different data series. For consistency with backtesting, using the Enter/Exit methods that specify the BarsInProgress index can help organize the order submissions so they are handled by the same data series.

    As for creating Auto Trail and Auto Breakeven functionality, this involves updating the stop loss order (from an Exit method) in OnBarUpdate. (Breakeven moves in association to Position.AveragePrice, while AutoTrail would move to the current/last price (Close[0] or Closes[X][0].) I removed the Auto Breakeven code from this example, but you can reference the original SampleOnOrderUpdate to see how a Breakeven is implemented there, and you would just have to mind using the Exit order method which specifies the BarsInProgress index of the data series you want to have fill the order.

    Original SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    93 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    123 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X