- ago
I'm attempting to setup a parameter as string.

CODE:
         AddParameter("Benchmark Symbol", ParameterTypes.String, "SPY");


When I do that and compile, I receive the following exception:
CODE:
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Double'. at WealthLab.Core.Parameter.get_AsDouble() at WealthLab.Core.Parameter.OrderListener() at WealthLab.Core.ParameterList.FixOptimizationValues() at WealthLab.WPF.ParameterSliderPanel.set_Parameters(ParameterList value) at CreatorInterpreter.SetupWorker(Object , ParameterList , CreatorInterpreter ) at WealthLab7.cwStrategy.MoveRecord() at WealthLab7.designerCode.Compile() at WealthLab7.designerCode.StartCode(Object item, RoutedEventArgs map) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
0
100
Solved
3 Answers

Reply

Bookmark

Sort
- ago
#1
Strategy parameters can only be Int32 or Double, since those are the only two types that can be optimized.
0
- ago
#2
Dion, maybe it could be more prudent with a clear compiler warning or something on trying to add an unsupported parameter type in UserStrategyBase?
1
Best Answer
- ago
#3
Agree, something a bit more friendly and maybe a note in the documentation would be helpful. I banged my head against a wall for a bit, thinking I was doing something silly and causing the issue, as other platforms I work in allow string parameters with strategies.
1

Reply

Bookmark

Sort