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

Select from string array in Properties grid

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

    Select from string array in Properties grid

    Bertrand has kindly provided a reference sample of various customised property grid items (https://ninjatrader.com/support/foru...ad.php?t=97919).

    I would appreciate a simple example for both NT7 and NT8 of a property grid dropdown to select from an array of strings.

    Most grateful for your assistance in this.

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Look carefully at the provided NT8 sample reference.

    Even though that reference file is designed for NT8, the C# code inside the region 'Use Case #4: Display "friendly" enum values' will probably work in NT7.

    Also, if you're a member of BMT, an example exists here,
    I've attached the indicators and will provide links as well. I'm also attaching a screenshot that shows both components of the smittyMASlopeMonitor more clearly than the previous post. The SmittyMASlopeMonitor indicator window has two main things it displays, which wasn't obvious from the original screenshot. It paints the background of the indicator window, which is either uptrend or downtrend. The other that thing that it prints is 5 moving averages. I changed the colors of the moving averages …

    Comment


      #3
      Hello jeronymite,

      I am unaware of an existing sample I could provide for this. For NT7 there weren't many samples related to the property grid on the support forum because NT7 uses the standard .net property grid that comes with Windows Forms. You can find a lot of complete examples online for Windows Forms property grid and the various properties it supports which also would work in NT7. Going forward in nt8 a custom property grid is used so there are some key differences which in turn allows us to provide more samples of it.

      Here is one example of a dropdown in C# using the winforms property grid: https://stackoverflow.com/a/24509383 which resulted from searching for the terms "C# winforms propertygrid dropdown".

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Select from string array in Properties grid

        Thanks Jesse and bltdavid. Very helpful.

        I have it working in both NT7 and NT8 as follows, specifically for a range of string values (hence the variable names). But I want to make it a bit more generic, so will continue to work on it.

        Common:
        Code:
        		public class StringSelectorConverter : TypeConverter
        		{
        			public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        			{
        				return true ;
        			}
        			public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        			{
        				StandardValuesCollection svc = new StandardValuesCollection(selection) ;
        				return svc ;
        			}
        		}
        		
        		static class RangeList
        		{
        			public static List<string> ranges = new List<string>() ;
        			static RangeList()
        			{
        				foreach (string sel in plotrangetype)
        					ranges.Add(sel) ;
        			}
        		}
        NT7:
        Code:
        		[Description("Range Selector.")]
        		[Category("Range Data")]
        		[Gui.Design.DisplayNameAttribute("Range")]
        		[RefreshProperties(RefreshProperties.All)]
        		[TypeConverter(typeof(StringSelectorConverter))]
        		public string _RangeSelection
        		{
        			get { return  RangeSelection ; }
        			set { RangeSelection = value ; }
        		}
        NT8:
        Code:
        		[TypeConverter(typeof(StringSelectorConverter))]
        		[PropertyEditor("NinjaTrader.Gui.Tools.StringStandardValuesEditorKey")]
        		[Display(ResourceType = typeof(Custom.Resource), Name = "Range", GroupName = "Range Data", Order = 4,
        				 Description="Range Selector.")]
        		public string _RangeSelection
        		{
        			get { return  RangeSelection; }
        			set { RangeSelection= value ; }
        		}
        Thanks.
        Multi-Dimensional Managed Trading
        jeronymite
        NinjaTrader Ecosystem Vendor - Mizpah Software

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        23 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        46 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        22 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X