The offending line is the following from your OnPositionUpdate() function ..
Print(string.Format("{0}", SystemPerformance.AllTrades[i].ToString()));
if (SystemPerformance.AllTrades.TradesCount > 0) { Print(string.Format("{0} AllTrades.TradesCount: {1}", Time[0], SystemPerformance.AllTrades.TradesCount.ToString())); for (int i = 0; i < SystemPerformance.AllTrades.TradesCount; i++) { //Print(string.Format("{0}", SystemPerformance.AllTrades[i].ToString())); } }
I can't print the values of that line because of the error below.
--
Strategy '<name>197047982': Error on calling 'OnPositionUpdate' method on bar 15310: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
--
If I comment out that offending line, or remove your OnPositionUpdate() function my strategy script works fine.
All I wanted was to write some values from each of the trades as they happen/exit into a file, I found your code when looking how to access trade info, so I thought looping through the trade list and printing the data was the first step, but I have not made it past that bit yet :?
I hope that clarifies the sequence of events .. I am in no way saying that our 2 x scripts are the same, they are not, but the OnPositionUpdate() is the same in both.
There is something going on in my script that is stopping me looping through the list of trades and extracting the data, which, I have no idea where to go with that .. should just work right ? am assuming you have not seen this before and its not a bug/defect ?
Is there some sort of low level debugger we can attach or run ?
Comment