Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Property TypeConverters on Indicators using AddChartIndicator()

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

    Property TypeConverters on Indicators using AddChartIndicator()

    I've got an indicator that uses the IndicatorBaseConverter Class described here: https://ninjatrader.com/support/help...econverter.htm

    I'm adding the indicator to the chart from a Strategy using AddChartIndicator.

    The strategy doesn't need all the properties of the base indicators and therefore some of the properties that the TypeConverter tries to access are missing. This causes an error when I open the indicators dialog on the chart.

    Is there any way from inside an IndicatorBaseConverter subtype to detect that the indicator is in the context of a Strategy's AddChartIndicator, so that I can override the logic? Or to disable the TypeConverter completely?



    #2
    Hello kevinenergy,

    I am not aware of a specific property that the indicator would know of for AddChartIndicator. Have you isolated a specific case that you can provide so we could further research that? For example do you see that if you use AddChartIndicator with the help guide sample for IndicatorBaseConverter? https://ninjatrader.com/support/help...r_to_custo.htm

    Comment


      #3
      Hi Jesse.

      I have tested this using a blank strategy and the guide sample. It throws a NullReferenceException when you open the indicator dialog box. and select the Indicator in the list.

      Code:
          public class MyCustomStrategy : Strategy
          {
              protected override void OnStateChange()
              {
                  if (State == State.SetDefaults)
                  {
                      Description = @"Enter the description for your new custom Strategy here.";
                      Name = "MyCustomStrategy";
                      Calculate = Calculate.OnBarClose;
                  }
                  else if (State == State.DataLoaded)
                  {
                      var sampleTypeConverterIndicator = SampleIndicatorTypeConverter();
                      AddChartIndicator(sampleTypeConverterIndicator);
                  }
              }
      
              protected override void OnBarUpdate()
              {
                  //Add your custom strategy logic here.
              }
          }​

      Comment


        #4
        Hello kevinenergy,

        It looks like you would need to add your own null checks for that use case, for example:

        if(toggleValue1 == null || toggleValue2 == null)return propertyDescriptorCollection;

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        59 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X