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.
[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"); } }
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?
Comment