Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exception saving templates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Exception saving templates

    Hello,

    I made a couple small changes to an indicator of mine yesterday, namely add Brush colour and Font to the configuration parameters. This all works fine, but I noticed today on startup the indicator had dissapeared from my workspace (again). I restored from the template, but my colour changes where not there (I'd not saved it again last time), so I tried to re-save the template with my new indicator colour settings. It fails with an XML error. I tried to also set the new colours as the default parameters for the indicator. Again, the xml parsing fails and NT throws an exception.

    From the indicator/code point of view, all works fine, so I'm not sure I've done anything wrong (code is per examples in the official code base)

    I simply added this to my settings. As I say, it works fine apart from this error in nt

    [NinjaScriptProperty]
    [Display(Name="Default Font", Description="Font Size", Order=1, GroupName="Font")]
    public SimpleFont myFont
    { get; set; }

    [NinjaScriptProperty]
    [Display(Name="Imbalance Font", Description="Font Size", Order=1, GroupName="Font")]
    public SimpleFont myImbalanceFont
    { get; set; }

    [NinjaScriptProperty]
    [Display(Name="BidColour", Description="BidColour", Order=1, GroupName="Font")]
    public SolidColorBrush BidColour
    { get; set; }

    [NinjaScriptProperty]
    [Display(Name="AskColour", Description="AskColour", Order=1, GroupName="Font")]
    public SolidColorBrush AskColour
    { get; set; }

    [NinjaScriptProperty]
    [Display(Name="BidColourImbalance", Description="BidColourImbalance", Order=1, GroupName="Font")]
    public SolidColorBrush BidColourImbalance
    { get; set; }

    [NinjaScriptProperty]
    [Display(Name="AskColourImbalance", Description="AskColourImbalance", Order=1, GroupName="Font")]
    public SolidColorBrush AskColourImbalance
    { get; set; }


    Here's the exception detail from the trace log. It's seems it cannot handle the brush?

    this is with 8.2 version

    2016-12-09 09:16:26:504 *************** unhandled exception trapped ***************
    2016-12-09 09:16:26:504 There was an error generating the XML document.
    2016-12-09 09:16:26:519 System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type System.Windows.Media.MatrixTransform was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriterpjsVolumeCluster.Write27_Transfo rm(String n, String ns, Transform o, Boolean isNullable, Boolean needType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriterpjsVolumeCluster.Write30_SolidCo lorBrush(String n, String ns, SolidColorBrush o, Boolean isNullable, Boolean needType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriterpjsVolumeCluster.Write31_pjsVolu meCluster(String n, String ns, pjsVolumeCluster o, Boolean isNullable, Boolean needType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriterpjsVolumeCluster.Write32_pjsVolu meCluster(Object o)
    --- End of inner exception stack trace ---
    at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
    at NinjaTrader.Cbi.Serializer.Serialize()
    at NinjaTrader.Gui.Tools.IndicatorSelector.OnIndicato rsPresetSave(IndicatorRenderBase selectedIndicatorBase)
    at NinjaTrader.Gui.Tools.IndicatorSelector.<.ctor>b__ 7_3(Object o)
    at NinjaTrader.Gui.Tools.ObjectDialog.OnPresetSaveCli ck(Object sender, RoutedEventArgs e)
    at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args)
    at NinjaTrader.Gui.Tools.PresetSlideout.<OnSaveClick> b__26_1()
    at System.Windows.Threading.DispatcherOperation.Invok eDelegateCore()
    at System.Windows.Threading.DispatcherOperation.Invok eImpl()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowF orNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.Handle NonSuccessAndDebuggerNotification(Task task)
    at System.Windows.Threading.DispatcherOperation.Wait( TimeSpan timeout)
    at System.Windows.Threading.Dispatcher.InvokeImpl(Dis patcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
    at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
    at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority)
    at NinjaTrader.Gui.Tools.PresetSlideout.OnSaveClick(O bject sender, RoutedEventArgs e)
    at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args)
    at System.Windows.Controls.Primitives.ButtonBase.OnCl ick()
    at System.Windows.Controls.Button.OnClick()
    at System.Windows.Controls.Primitives.ButtonBase.OnMo useLeftButtonUp(MouseButtonEventArgs e)
    at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler, Object target)
    at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target, RoutedEventArgs routedEventArgs)
    at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.ReRaiseEventAs(Dependency Object sender, RoutedEventArgs args, RoutedEvent newEvent)
    at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
    at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler, Object target)
    at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target, RoutedEventArgs routedEventArgs)
    at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args)
    at System.Windows.UIElement.RaiseTrustedEvent(RoutedE ventArgs args)
    at System.Windows.Input.InputManager.ProcessStagingAr ea()
    at System.Windows.Input.InputManager.ProcessInput(Inp utEventArgs input)
    at System.Windows.Input.InputProviderSite.ReportInput (InputReport inputReport)
    at System.Windows.Interop.HwndMouseInputProvider.Repo rtInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
    at System.Windows.Interop.HwndMouseInputProvider.Filt erMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at System.Windows.Interop.HwndSource.InputFilterMessa ge(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.Internal RealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

    #2
    Hello pjsmith,

    Thank you for your post.

    Are you ensuring you are serializing the brush colors? I recommend using the example at the following link as a guide: http://ninjatrader.com/support/forum...43&postcount=2

    Comment


      #3
      Thank you. I was not.

      There is no such requirement for fonts (SimpleFont) ?

      Comment


        #4
        pjsmith,

        This would not be needed for SimpleFont.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        53 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        32 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        4 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        19 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        6 views
        0 likes
        Last Post cre8able  
        Working...
        X