When submitting the order, the calculations to determine where to place the order utilize various indicators and DataSeries. When this logic is called via OnBarUpdate it works. When the logic is called via a button click it throws an exception whenever a DataSeries is touched saying: 'Index was out of range...'. The exception occurs on a line like this:
long vol = Volume[barsAgo];
I am familiar with this error and have verified that the index is within range. I have also verified that the DataSeries.Count is valid. When I call the method Volume.IsValidDataPoint(barsAgo) fails with the same exception.
My theory is that DataSeries instances may only be accessed by certain thread contexts, specifically those initiated or controlled by Ninja. So when I click on the button, which is now the general GUI thread, the context is not correct and the access to Volume[barsAgo] fails.
Is this theory correct?
My button logic currently uses strategy.Dispatcher.InvokeAsync to invoke the logic.
So that attempt to get on the correct thread is not working.
Does Ninja provide a way to get my logic to process on a Ninja thread with the proper context?
Is the threading theory wrong?
Can anyone shed some light on this problem?
Thanks,
Gary
Comment