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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X