Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Live until cancelled order without BarsInProgress index

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

    Live until cancelled order without BarsInProgress index

    I'll try to explain what I'm intending to create and whether it's possible the best I can.

    I'm trying to make a Multi-Instrument strategy, that loads say 30+ symbols. Criteria for entries are just copied and pasted under 30+ BarsInProgress == 0 till BarsInProgress == 30 if statements.

    Entries are all taken fine but the stops is where I'm hitting some issues. The way I'm trying to place stops is using the OnPositionUpdate() method.

    The problem is this: How would the stop differentiate on which symbol to place the stop on. The way I would do it for a single symbol is something like this, where different initial stop is used based on the entry taken: entryOrder1 would be one entry criteria while entryOrder2 would be a different entry criteria.

    Code:
     
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnPositionUpdate(IPosition position)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [/SIZE][/FONT]if (entryOrder1 != null && position.MarketPosition == MarketPosition.Long)
    {
    stopOrder1 = ExitLongStop (0, true, Position.Quantity, Low[0] - StopIncrement, "Trail Stop", "Entry");
    }
     
    if (entryOrder1 != null && position.MarketPosition == MarketPosition.Short)
    {
    stopOrder1 = ExitShortStop (0, true, Position.Quantity, High[0] + StopIncrement, "Trail Stop", "Entry");
    }
     
    if (entryOrder2 != null && position.MarketPosition == MarketPosition.Long)
    {
    stopOrder2 = ExitLongStop (0, true, Position.Quantity, MIN(Low, 3)[0] - StopIncrement, "Trail Stop", "Entry");
    }
     
    if (entryOrder2 != null && position.MarketPosition == MarketPosition.Short)
    {
    stopOrder2 = ExitShortStop (0, true, Position.Quantity, MAX(High, 3)[0] + StopIncrement, "Trail Stop", "Entry");
    }
    }
    I supose my dillema is, how would I generalize this so it automatically places these stop orders for the correct instrument and not the one whose BarsInProgress index is 0, while still retaining the LiveUntilCancelled status.

    Let me know if further clarification is needed.

    EDIT: For example, entryOrder1 may come from BarsInProgress == 14, or it may come from BarsInProgress == 20, is there a way to "detect" which BarsInProgress index it came from so that the stop can be placed for the correct index?
    Last edited by bani789; 09-02-2008, 01:11 PM. Reason: Typos

    #2
    Aren't you using individual IOrder objects for each of your instruments? If the order comes from the IOrder that stemmed from instrument 1 you will know which barsInProgress to submit to. Just change the 0 to 1 for the barsInProgressIndex parameter.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    627 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 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
    562 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    567 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X