If I use BacktestType=Standard there is no problem but if I use BacktestType=Optimization then I get the error
I presume the difference is that BacktestType=Standard probably runs on a single thread whereas BacktestType=Standard uses multiple threads. So perhaps the quoted error is due to NT8 not yet making IsValidDataPoint thread safe?
There are a few problems here:
1) Documentation for MaximumBarsLookBack does not match the current code:
The page currently says
2)The example code on IsValidDataPoint documentation is silly since it uses SMA which sets Value for every bar. In order to test IsValidDataPoint we need a new SMA indicator that only starts plotting after Period inputs.
Steps to reproduce problem:
a) Edit SMA indicator save as SMATest.
SMATest is minimally changed so it only starts setting Value after it gets Period inputs:
sum = priorSum + Input[0] - (CurrentBar >= Period ? Input[Period] : 0); [COLOR="Green"]if (CurrentBar+1 < Period) return;//New line. Dont set Value until have Period values in sum[/COLOR] Value[0] = sum / (CurrentBar < Period ? CurrentBar + 1 : Period);
BarsRequiredToPlot = 0;//Value not plotted until have Period values in sum
b) Edit strategy SampleMACrossOver, save as TestMACrossOver
Change SMA references to SMATest.
Also add a diagnostic Print
else if (State == State.Configure) { smaFast = SMATest(Fast);//changed smaSlow = SMATest(Slow);//changed [COLOR="Green"] BarsRequiredToTrade = 0; Print(string.Format("smaSlow.MaximumBarsLookBack = {0}",smaSlow.MaximumBarsLookBack));//reports TwoHundredFiftySix[/COLOR]
[COLOR="Green"]if (!smaSlow.IsValidDataPoint(0)) return;//new line[/COLOR] if (CrossAbove(smaFast, smaSlow, 1))
When you run TestMACrossOver in Strategy Analyzer BacktestType=Standard you see there is no error, also in the Output window you see
Now comment out the Print line.
Run TestMACrossOver in Strategy Analyzer BacktestType=Optimization (Optimizer=Default). Set a small number of combinations (here just 2) say Fast range 2 to 3, Slow range say 4.
On my PC (multi-core) this tends to keep going producing 2 error lines per run
Restarting NT8:
If I try the same thing but with Optimizer=Genetic, then I see I get 8 lines of the error (probably 1 per thread, or one per core) but Strategy Analyzer does not lock up, I dont have to Abort and I can keep repeating this without NT stopping.
So error handling in the Genetic Optimizer seems to be much better than the Default Optimizer.
If I switch to using SampleMACrossover: I get no operational problems with either Optimizer (there's just the mathematical problem that the built in SMA plots before it has Period inputs).
It looks like the current implementation of IsValidDataPoint has not been tested in a multi-threading context such as Optimization.
Comment