Errors | Strategy

Modified on 2021/07/02 06:10 by Eugene — Categorized as: Knowledge Base

Strategy Monitor doesn't work



Problem:

Suddenly, Strategy Monitor stopped generating orders. The log contains similar lines:

9/25/2013 10:47:18 AM: Update Completed: AAPL, LastDate=9/25/2013 11:46:00 AM, O=483.16 H=483.2399 L=482.61 C=482.8199 V=16646 Count=916, AAPL,OHLCV
9/25/2013 10:47:18 AM: Skip Update (not current): AAPL (916)

9/25/2013 10:34:19 AM: Update Completed: AAPL, LastDate=9/25/2013 11:33:00 AM, O=483.08 H=483.25 L=483.041 C=483.19 V=16451 Count=902, AAPL,OHLCV
9/25/2013 10:34:19 AM: Deleted 1: AAPL

Reason:

  1. These lines indicate that the SM considered the data not current, thus skipping the update (1st log) or deleting N bars from the updated data (2nd log) because it thought that they were timestamped beyond the "Next Run".
  2. Another possible reason is trading in illiquid symbols.

Solution:

  1. Your PC clock is set incorrectly, confusing the SM. Synchronize your PC clock.
  2. Get rid of the illiquid symbols or switch to a higher bar scale.



Problem:

You run strategies from the Strategy window, but cannot add them to the Strategy Monitor. When you try to open the Strategy Monitor, you get an error message that starts like this:

System.InvalidOperationException: There is an error in XML document (0, 0). System.Xml.XmlException: Root element is missing.
...

...or like this:

System.ArgumentException: Tick scale is not supported
at WealthLab.MarketHours.GetNextTimeStamp(DateTime timeStamp, BarDataScale scale)
at WealthLabPro.StrategyCenterItem.CalculateNextRun(Boolean forceToFuture)
at WealthLabPro.StrategyCenterForm.c()
...



Reason:

The Strategy Monitor configuration file (StrategyMonitorConfiguration.xml) got broken. The numbers reported in the exception message can vary: if they're (0, 0) then the config file is empty i.e. its size is 0 bytes, if there's a larger number, then the file is broken at its end. In this case, you may contact support by entering a new ticket.

Solution:

To have Strategy Monitor up and running again, please enable hidden file/folder visibility (Control Panel > Folder Options), locate the StrategyMonitorConfiguration.xml file and delete it:


Problem:

Strategy Monitor doesn't work, producing an unhandled exception window when trying to open its window or add a strategy on 1-10 minute bar intervals:

System.NullReferenceException: Object reference not set to an instance of an object.
   at WealthLabPro.StrategyCenterForm.a(StrategyCenterItem A_0, Boolean A_1)
...

Solution:

You have not selected a Streaming provider in Wealth-Lab's Preferences dialog. Open Preferences (F12) and choose suitable Streaming provider.



Problem:

When Strategy Monitor is opened, you get an error message saying that Current TimeZone not found that looks like below:

Current TimeZone not found.

System.ArgumentException: CurrentTimeZone not found.
at Fidelity.Components.TimeZoneInformation.get_CurrentTimeZone()
...

Solutions:

1. In Windows, Internet time synchronization is enabled. Disable it.

2. (Applies to: Windows Ultimate or Enterprise). You're using a localized (e.g. German) Windows Ultimate. This version lets you change the system language and you changed Display Language or all language options to English.

As a workaround, change your Display Language back to native (e.g. German). On Windows 10, restarting PC after applying the change seems to do the trick.

This can also be caused by installing an additional language pack on Windows Pro.

3. If you've changed the time zone in Windows recently, try reverting the change.

4. New: Microsoft input keyboard is known to cause this error with multiple languages added. If the default language is set to English, it changes to another user-specified language on WL startup. Solution: remove all other languages.

Problem:

Lately, Strategy Monitor's performance has slowed down considerably. Strategy execution time gradually increases. What took a few seconds to run now consumes a minute or more. Resetting the configuration file does not help.

Workaround:

The issue affected one customer and presented itself following a Windows automatic update which brought new versions of:

  1. Skype
  2. Microsoft Windows Desktop Runtime 3.1.1.16 (x64)

After uninstalling these program(s) and rolling back the SM performance is back to normal.





Strategy editor does not function



Problem:

The application mostly works as expected but you're unable to open any Strategy editor window (either a saved or a new strategy). On the other hand, rule-based strategies are working fine. This error can arise after upgrading.

If you expand the exception dialog to view error details, this information is present:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
...

Reason:

Due to the editor component upgrade in WL5.3, there was a configuration file format change that sometimes results in an unhandled exception. You can be affected by this bug if you either have deleted the application's configuration file, WealthLabConfig.txt (see "Data > Where Data is stored" in the Wealth-Lab User Guide), or have a user selected color theme. Make sure hidden file/folder visibility is enabled in Windows Control Panel > Folder Options!

Solution:

There are 4 workarounds:
Problem:

Lines of WealthScript code in the Editor are being moved every Nth run, won't stay in place.

Reason:

You're running TeamViewer or related remote control system.

Solution:

Close TeamViewer. On a related note, Skype's Click To Call function is known to interfere with clipboard at least with MS Office programs, so be sure to check this too.



WL6 crashes on compiled strategy



Problem:

Valid Strategy crashes Wealth-Lab for no good reason.

Solution:

Sometimes, crash can be produced by a drag and drop indicator saved with the Strategy (especially when the indicator has had a breaking change). Click "Clear Drag and Drop Indicators" and rerun, or copy and paste the Strategy code into a new Strategy window.

Problem:

You're using Visual Studio or SharpDevelop to create a compiled strategy (which runs successfully in Wealth-Lab's built-in editor), the DLL files have been placed to WL6 main folder, but when WL6 is launched, the loading of the newly created DLL is crashing WL6.

Solution:

If you had the IDE to add all the stubs automatically (code completion) into the StrategyHelper class, by default they throw an exception. Be sure to replace the stubs with your code.

Problem:

Wealth-Lab crashes after putting a compiled Strategy library in main program folder with a similar error:

System.ArgumentException was unhandled
  Message=Empty path name is not legal. (...)
       at System.IO.FileStream.Init...
       at System.IO.FileStream..ctor...

Solution:

If using 32-/64-bit installations of Wealth-Lab, verify that you didn't mix references to the Wealth-Lab assemblies from a different "bitness".



Strategy compiles but produces a specific runtime error



Problem:

When executing a Strategy with successfully compiled code (only), you're getting error message(s) in the debug log that read like this:

Unable to cast object of type 'WealthLab.DataSeries' to type 'WealthLab.Indicators.MACD'.

The message may vary depending on the Indicator used in your code.

Solution 1:

This error can happen when a Strategy is being executed in non-native time scale. For example, the DataSet is Daily and you select "60 Minute" from the Data Loading control before executing the code. However, you don't have the intraday data already available with on demand updates turned off. Therefore this message indicates that you don't have available data for one of the symbols in the DataSet in requested time frame (e.g. intraday minute-based). This obviously applies to "lower" time scales because Wealth-Lab would easily upscale from Daily to Weekly, for instance.

  1. Create a DataSet in required time scale (e.g. 30-minute)
  2. Download the full set of data
  3. Execute the Strategy

Remember to create and update a DataSet in desired time frame prior to operating a Strategy.

Solution 2:

Sometimes this error can be caused by dragged and dropped indicators. Their settings are saved within the Strategy's XML file so to get rid of the exception you need to reset them. For that, focus on the Strategy's chart window and click the "Clear Drag and Drop Indicators" button.



Problem:

You've created some valid code that compiles and should execute, but when you try running it, it produce the following error (only):

 Runtime error: Cannot convert 1936003584 Bars to Daily Scale

Solution:

Runtime errors about bar conversion like this can be a sign of data error. Refer to How to delete (e.g. broken) data files? in FAQ on Data and Data Providers.



Problem:

You've created some valid code that compiles and should execute, but when you try running it, it produce the following error (only):

 
Runtime error: Value of '7' is not valid for 'Value'. 'Value' should be between 'minumim' and 'maximum'.
at WealthLabPro.Chartform.q()
at WealthLabPro.Chartform.o()
at WealthLabPro.Chartform.b(Int32 A_0, Object A_1)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)

Solution:

Close and re-open the strategy window or restart WL6.



Problem:

Your otherwsie valid code that may run, produces the following error with certain Data Loading Range settings:

Cannot Synchronize, no overlapping Dates.

Solutions:

  1. The symbol you're trying to synchronize to the current symbol doesn't have any dates that correspond to the current symbol. For example, the data for stock "A" exists from 1950 to 1990, but for the stock "B" (the one you're charting) starts after 1990 - there's no overlap for synch.
  2. You have a Benchmark Buy & Hold symbol defined in Wealth-Lab's Preferences but symbols you're trying to backtest have no bars after the Benhcmark symbol's inception.
  3. If code uses SetContext (symbol) and the symbol is in lower case (e.g. aapl, try entering it in upper case (AAPL).



Problem:

You're getting the following error when using PlotSeries:

Runtime error: Plotted DataSeries has fewer bars than the Symbol being charted.

Solution:

For example, the error could arise when using this code:

SetScaleCompressed(120);
DataSeries TheSeries = ATR.Series(Bars,5);
RestoreContext();

The mistake here is to use RestoreContext (which is N/A because you haven't changed the context) - actually, you needed to use RestoreScale instead.



Problem:

  1. You have a long-running strategy.
  2. Or you have streaming charts and/or strategy windows that get some external symbol(s) data.

You get the following error message(s):

Runtime error: An executing Strategy blocked a streaming data update. The Strategy run was terminated.

The process cannot access the file: \Path\external symbol.WL

Reason:

It's by design. The message is telling that Wealth-Lab is trying to update the Bars object while it was locked by one of your Streaming stategy windows. That could happen when a bar closes while one of your long-running Strategies is still executing or a streaming strategy is being initialized when Wealth-Lab is about to update the bar. To avoid a streaming crash, Wealth-Lab aborts the strategy to guarantee that it won't break streaming updates. Side-effect: multiple Strategy windows are essentially prevented from using the same external symbol.



Problem:

You get the following error message:

Runtime error Bar number must be 5590 or greater at WealthLab Strategies MyStrategy Execute()...

Reason:

This is like a getting an index out of bounds error. Your code violates the boundary by accessing a bar which does not exist. Make sure you're not accessing a value at a bar which is less than 0 or greater than Bars.Count.



Problem:

You're getting the following error in Debug window when executing a Strategy:

"DataSeries do not have equal number of values for mathematical operation"

Solution:


Problem:

You're getting one of the following errors in Debug window when executing a Strategy on a compressed scale (e.g. 1-minute to 30-minute):

"Runtime error: Attempting to Deserialize an empty stream."

"Runtime error: Value cannot be null. at WealthLabPro.ChartForm... at WealthLabPro.MainModule.LoadExternalSymbol... at WealtLab.DataProviders..."

Solution:

1. It can happen when creating a Strategy that makes a request to an external symbol and uses multiple timeframes. When Wealth-Lab couldn't find the symbol in the requested bar scale, the runtime error is triggered. Try using the overloaded call that allows to specify the DataSet that will be searched when your external symbol is requested.

//Bars s1 = GetExternalSymbol("csfb", true);
Bars s1 = GetExternalSymbol("your DataSet with CSFB name here", "csfb", true);

2. Another possibility is that you have checked "Benchmark Buy & Hold" in Wealth-Lab's Preferences (F12) > Backtest Settings. Disable that option.





Compiler error messages



Problem:

You're getting an error message like these when compiling a Strategy:

CS0246 @ (5.1): The type or namespace name 'Community' could not be found (are you missing a using directive or an assembly reference?)
CS1513 @ (93.3):} expected. etc.

Solution:

These are syntax and similar errors in your code. Use the MSDN (or other search engine) to find the error description and solution in MSDN e.g.




Index was out of range



If you're getting this "Index out of range" error message in Debug window when running a Strategy, this means you're actually violating the bounds in some way. For example:


If this message only happens with some symbols and not others, it is possible that a drawing object for that symbol (DRW file) and bar scale has got corrupt. To fix, click the Eraser button atop the Drawing Objects toolbar ("Clear Drawing Objects").

If using ASCII data, double check that it doesn't have duplicate entries (i.e. two rows for one date) and/or incorrect order of months.



Object reference not set to an instance of an object



Note: this is a pretty multifaceted error message - it can happen outside of a Strategy. But should you experience the run-time error in your Strategy telling you that "Object reference not set to an instance of an object", you need to know that there's a variable that has not been initialized, in other words it's null. Either you haven't assigned a value to some variable, or a method/function that you called has set the variable to null.

If "Benchmark Buy & Hold" symbol is defined and enabled in the Wealth-Lab's Preferences dialog, Backtest Settings, or your system uses an external symbol's data, you should make sure that the symbol name (or DataSet name) is valid and could be found in your DataSets. Entering a symbol that does not exist or has no data is a popular reason for getting this error message in backtests.

If it occurs on some particular symbol, it is also possible that a drawing object for that symbol and bar scale has got corrupt. To fix, click the Eraser button atop the Drawing Objects toolbar ("Clear Drawing Objects"). If this doesn't work then try reloading data (right click on the chart and select "Reload Chart History").

A less likely cause of this message if it happens on startup is when default workspace uses a ChartStyle that is not installed.

If the message reads "Object reference not set to an instance of an object. Unable to get Data on Demand for symbol: XXXX", uncheck "Update Data on Demand" in the Data Manager.