can any of you explain why the following has to be called within ChartControl.Dispatcher.InvokeAsync () ? Can I just place all codes within OnButtonClick() with using InvokeAsync?
much appreciated !
{
ChartControl.Dispatcher.InvokeAsync((Action)(() => {
Account a = ChartControl.OwnerChart.ChartTrader.Account;
int quantity = ChartControl.OwnerChart.ChartTrader.Quantity;
AtmStrategy atm = ChartControl.OwnerChart.ChartTrader.AtmStrategy;
Instrument instr = ChartControl.OwnerChart.ChartTrader.Instrument;
Order order1 = a.CreateOrder(instr, OrderAction.Buy,
OrderType.Market, OrderEntry.Automated, TimeInForce.Day, quantity, 0, 0, "", "Entry",
Core.Globals.MaxDate, null);
Order order2 = a.CreateOrder(Cbi.Instrument.GetInstrument ("NQ 12-24"), OrderAction.SellShort,
OrderType.Market, OrderEntry.Automated, TimeInForce.Day, quantity, 0, 0, "", "Entry",
Core.Globals.MaxDate, null);
if (atm == null)
// was set to 'None'
a.Submit(new[] { order1,order2 });
}));
}

Comment