I have an indicator attached to a Market Analyzer, which submits orders with an attached 'ATM1' strategy. The Market Analyzer contains two instruments: 'A' and 'B'. The 'ATM1' strategy is already active for both instruments, and an order has been placed for each instrument.
I want to modify the indicator so that it closes the 'ATM1' strategy and exits the trade using a market order when a specific condition is met. My question is:
- Can I use the following code snippet to exit the trade if the condition is true for Instrument A but not for Instrument B?
- If the condition is True for Instrument A but false for Instrument B, will the below code exit the 'ATM1' strategy and close the position for Instrument A only, or will it close the positions for both instruments?
protected override void OnBarUpdate() { if (Condition == True) { foreach (StrategyBase strat in myAccount.Strategies) { strat.CloseStrategy("Close Strategy"); } } }
Comment