I have discovered that the "AddBars" in a script for certain instruments causes Ninja to lock itself (Ninja + IQFeed). This is with the newest release of Ninja7.
In the above video, you can see:
1 - Top left - Process Explorer search that shows who is locking the file "201602191700.Last.ntd" - as you can see Ninja and only Ninja has a handle on that file. This means that no other process (such as AV/search indexer) is locking the file
2 - I then add the indicator "TestFileLock" to YM 03-16
3 - We see the message in the log : IQFeed.Adapter.MessageLoopBars msg='!ENDMSG!,': The process cannot access the file 'G:\Documents\NinjaTrader 7\db\tick\YM 03-16\201602191700.Last.ntd' because it is being used by another process.
4 - I refresh Process Explorer and still only Ninja has a file lock on the file.
5 - Ninja is now dead. I cannot close the indicator window (but can move it) and all other windows are unresponsive.
Now - I do understand that when you see this issue, it is mostly because some 3rd party app is locking the file. That is not the case here, I can run this over and over again, checking that no app has a handle on the file before I add the indicator and then again after. In all cases, only Ninja has the lock.
It is safe to conclude that Ninja has locked itself out.
This happens with YM and I heard from customers it occurs on other instruments like TF.
In my testing it does not occur in ES, ZB, ZC, Bund, Dax, ZN, ZF. CL
As for the indicator I placed on the chart, it is "TestFileLock.cs". It is a copy of the EMA.cs
The only difference between the EMA.cs and this version is the Initialize section:
protected override void Initialize() { Add(new Plot(Color.Orange, "TestFileLock")); Overlay = true; Print(Instrument.FullName + " Adding 1 tick bars"); try { Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last); } catch (Exception e) { Print(e.ToString()); } Print(Instrument.FullName + " After Adding 1 tick bars"); }
Comment