Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

List of Parameters

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

    List of Parameters

    Is there a way to know how many ninjascript parameters are created in a custom indicator. What I want to do is create my own template and save my own ninjatrader indicator template. I want to scroll through my parameters and create an array for export.

    Example: MACD parameters 12, 24 ,9. These parameters I want to save. I know I can go through manually and create a script, but I have 20 plus indicators to harvest parameters.

    #2
    Hello ballboy11,

    You may be able to use reflection.

    Below are a few threads within something similar.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you .
      I got most of the stuff to work but am having an issue in color.

      This is what I have.

      This is the first thing I tested
      // ################################### my parameters ######################
      private Brush eBox1Color = Brushes.Khaki;
      [XmlIgnore()]
      // [NinjaScriptProperty]
      [Display(Name = "Box 1 Color", Description = "", GroupName = "Box 1", Order =1)]
      public Brush Box1Color
      {
      get { return eBox1Color; }
      set { eBox1Color = value; }
      }

      // Serialize Color object
      [Browsable(false)]
      public string Box1ColorSerialize
      {
      get { return Serialize.BrushToString(eBox1Color); }
      set { eBox1Color = Serialize.StringToBrush(value); }
      }

      // ################################### my parameters ######################


      ############# my failed test code #########################################

      eBox1Color = (SolidColorBrush)new BrushConverter().ConvertFromString(sMyString);

      // ############################ test 2 failed ####################################

      var converter = new System.Windows.Media.BrushConverter();
      var brush = (Brush)converter.ConvertFromString(sMyString]);
      eBox1Color = brush;


      //############################## test 3 a function I made that failed ###################################

      eBox1Color = FindColor(sMyString);



      public Brush FindColor(string sColor)
      {
      Brush asd = Brushes.AliceBlue;;
      asd = Serialize.StringToBrush(sColor) ;

      return asd;

      //############################## test 4 a function I made that is successful ###################################

      eBox1Color = FindColor(sMyString);

      public Brush FindColor(string sColor)
      {
      Brush asd = Brushes.AliceBlue;;

      if( sColor == "#FFFFA500") // just testing my script color
      asd = Brushes.Purple;

      return asd;
      }


      How do I load my saved color into the

      private Brush eBox1Color parameter?

      I don't want to write 100 if statements for each color.


      ​​​​​​​

      Comment


        #4
        Hello ballboy11,

        Thank you for your reply.

        I wanted to check, is the question on how to serialize the color property or are you trying to make this automated to accommodate multiple brushes? It looks like you may be trying to convert a hex code into a brush, is that the question?

        We have some information about working with brushes in the following link as well: https://ninjatrader.com/support/help...definedbrushes

        I look forward to being of further assistance.

        Comment


          #5
          Yes I am trying to convert a hex string back to a brush. Instead of saving template I created my indicator to save all my parameters in a file. When loaded I want to grab the hex code and convert the parameter brush to that color.

          Comment


            #6
            Hello ballboy11,

            Thank you for your reply.

            When you save to a file are you serializing your class or doing something else?

            If you are serializing the class, you should be able to use the format of having a brush property and using a second property with BrushToString/StringToBrush used. If that was not working for you, I would need more specific details about the errors seen or what specifically happened in that test. If you are doing something else with the brush to save it, you can still make use of the conversion methods.

            For example:

            Code:
            Print(Serialize.BrushToString(Brushes.Red));
            Will produce an output of:

            <SolidColorBrush xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">#FFFF0000</SolidColorBrush>
            As long as this is the string you give to the opposite method it will create the brush:

            Code:
            System.Windows.Media.Brush r = Serialize.StringToBrush("<SolidColorBrush xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">#FFFF0000</SolidColorBrush>");
            Print(r.ToString());
            I look forward to being of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            81 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            41 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            64 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            66 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X