Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 zstheorist, Today, 07:52 PM
      0 responses
      7 views
      0 likes
      Last Post zstheorist  
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      150 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      6 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      6 views
      0 likes
      Last Post tkaboris  
      Working...
      X