Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

User property based on derived stroke

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

    User property based on derived stroke

    Hi there,

    I'm trying to implement a user property based on an expandable derived Stroke object (e.g. LegendStroke) in order to hide the Stroke object's DashStyleHelper and Width properties from NinjaTrader's indicators UI. A user property based on a non-derived Stroke object works fine (e.g. expandable/collapsible, usable values, etc.) however replacing that user property's type (Stroke) with the custom derived type (LegendStroke) results in a "NinjaTrader.Gui.Tools.ObjectDialogViewMode'1.OnAd dItem(Object selected)..." abort/retry/ignore message box and if ignored raises an "Unhandled exception: Non-static method required a target" error. Sample code is below, of which I tried commenting out the [Browsable(false)] statements, but no luck.

    namespace MyCustomNamespace.Strokes
    {
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class LegendStroke : Stroke
    {
    public new Brush Brush { get { return base.Brush; } set { base.Brush = value; } }

    [Browsable(false)]
    public new DashStyleHelper DashStyleHelper { get { return base.DashStyleHelper; } set { base.DashStyleHelper = value; } }

    public new int Opacity { get { return base.Opacity; } set { base.Opacity = value; } }

    [Browsable(false)]
    public new float Width { get { return base.Width; } set { base.Width = value; } }
    }
    }

    Suspecting I'm missing something key to making derived expandable types work correctly in NinjaTrader, I also tried doing a similar derived expandable type test by implementing a user property based on a non-derived SimpleFont type (worked great) and derived SimpleFont property (LegendFont) and unfortunately received the same "Non-static method required a target" error message. The font-related code is below (uses newer style getter and setter syntax, but functionally equivalent to the older style getter and setter syntax above).

    namespace MyCustomNamespace.Fonts
    {
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class LegendFont : SimpleFont
    {
    public new bool Bold { get => base.Bold; set => base.Bold = value; }

    public new bool Italic { get => base.Italic; set => base.Italic = value; }

    public new FontFamily Family { get => base.Family; set => base.Family = value; }

    public new double Size { get => base.Size; set => base.Size = value; }
    }
    }

    Does anyone know how to correctly implement derived Stroke (or SimpleFont) user properties within NinjaScript?

    Thanks!
    -Cary

    #2
    Hello caryc123,

    This advanced custom C# code would be outside of what is directly supported by NinjaTrader support.

    There can be limitations using advanced C# concepts, in NinjaScript, so your mileage may vary. As of now, we do not have any examples that can be used to navigate that path.

    I can provide a link to the reference sample on TypeConverters you may find helpful for an expandable object, however this will not have any demonstration of inheriting from the Stroke class.


    This thread will remain open for any community members that would like to assist.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea, I appreciate your detailed response. Perhaps a future version of NinjaTrader will enable support for my use case.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      597 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      343 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      556 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      555 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X