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 defined Variables: Font? Enum Pull-Down list?

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

    User defined Variables: Font? Enum Pull-Down list?

    Can anyone help me figure out how to pass a Font through an indicator's input parameter list? It's possible, because chart properties has a font as an input, including its associated sub-variables (type, size...).

    Also, how to get a pull-down for a fixed enumerated list (for example plot line styles - there's a fixed set from which user selects using a pull-down). How do I add parameters like that to my indicator?

    The wizard doesn't help for these non-numeric variables. Fixing that would be a good solution as well.

    Are there ANY examples? I am happy to plagarize from a sample....

    Thanks!!

    #2
    Got parameter enum pull-down worked out

    OK, I figured out how to get a pull-down list. The properties methods already recognize existing NT variables such as the TextPosition used by DrawTextFixed() so those are EASY. Now I still need a sample of passing in a complete font as an input parameter.

    Example for
    private TextPosition volPosition = TextPosition.TopRight;

    [Description("Position of text message in the panel")]
    [Category("Text")]
    [NinjaTrader.Gui.Design.DisplayName("Text position")]
    public TextPosition GetDTFPosition
    {
    get { return volPosition; }
    set { volPosition = value; }
    }

    For a custom list, it would be very similar:

    public enum SillyNames
    {
    Harri,
    HoHum,
    Horrid,
    }
    private SillyNames you = SillyNames.Harri;


    public SillyNames GetName
    {
    get { return you; }
    set { you = value; }
    }

    Comment


      #3
      Getting a font parameter is just a matter of using C#. You can try looking into the MSDN to see if you can find anything there.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Example Font input variable

        Here is an example of passing in a complete font as an input parameter.

        Example for
        private Font fv = new Font("Arial", 10, GraphicsUnit.Point);

        [XmlIgnore()]
        [Description("Font of the text message")]
        [Category("Custom")]
        [NinjaTrader.Gui.Design.DisplayName("Text font")]
        public Font Text_Font
        {
        get { return fv; }
        set { fv = value; }
        }
        [Browsable(false)]
        public string Text_FontSerialize
        {
        get { return NinjaTrader.Gui.Design.SerializableFont.ToString(f v); }
        set { fv = NinjaTrader.Gui.Design.SerializableFont.FromString (value); }
        }

        The variable type 'Font' MUST have a capital 'F'

        the XmlIgnore line and serialize method are required to avoid errors when saving the chart template, and so that the indicator will REMEMBER changes.

        Comment


          #5
          Thanks

          Thanks LostTrader, that helps. I put your suggestions to good use. Thank you for sharing them.

          Comment


            #6
            Customizing and Saving parameters as defaults

            1. Is it possible to capture parameters in a Strategy in NT6.5 and save them as defaults so the user does not have to re-enter them everytime the strategy is used?

            For example, I have a strategy in which the user may enter a personal sound wave file, but how can it be saved permanently?

            2. How can I create category areas in NT6.5, and not have to have all my parameters under the "Parameters" category?
            I tried using [NinjaTrader.Gui.Design.DisplayName("Sample Category Area")], but it does not create a new area, like it is possible in NT7.
            Last edited by rperez; 08-19-2010, 09:19 PM.

            Comment


              #7
              rperez,

              1. This is unfortunately not supported in 6.5

              2. To create a new category just setup your properties under the desired new category name - i.e.

              Code:
               
              [Description("Period for slow MA")]
              [Category("MA Periods")]
              public int Slow
              {
              get { return slow; }
              set { slow = Math.Max(1, value); }
              }
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Thanks Betrand,

                1. Too bad
                2. I've tried that, but it doesn't work. When I name my categories, the corresponding parameters simply do not appear in the Parameters Window.

                The attached code shows a parameter that dissapeared when I set the new category name.

                [Description("Print debugging control messages to the 'output window'?")]
                [Gui.Design.DisplayName ("1. Performance: Print debugging breaks to the 'output window'? ")]

                [Category("Performance")]
                public bool ImprimirResultadosParciales
                {
                get { return imprimirResultadosParciales; }
                set { imprimirResultadosParciales = value; }
                }
                Last edited by rperez; 08-20-2010, 08:53 AM.

                Comment


                  #9
                  rperez, could not reproduce here on 6.5 - works for me - where are you testing? In the Strategy Analyzer?

                  Thanks
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    No Bertrand, in a strategy I coded and am running now live (sim).

                    Comment


                      #11
                      You're right, on the chart you would unfortunately only see Parameters, on the SA and Strategies tab you should see also the custom ones.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        So, the'res no way in NT6.5 to add new categories to the running strategies?

                        Comment


                          #13
                          None that I'm aware of unfortunately, we added support for this with NT7.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            How about this problem.

                            How to serialized time parameter?. How to create/serialized an audio file?. A drop-down list of audio file? Anyone could help me on this problem.

                            Comment


                              #15
                              Unfortunately this is outside of the scope we can support here, however for enums in general this should be handy - http://geekswithblogs.net/claeyskurt.../19/85667.aspx
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bmartz, 03-12-2024, 06:12 AM
                              4 responses
                              31 views
                              0 likes
                              Last Post bmartz
                              by bmartz
                               
                              Started by Aviram Y, Today, 05:29 AM
                              4 responses
                              11 views
                              0 likes
                              Last Post Aviram Y  
                              Started by algospoke, 04-17-2024, 06:40 PM
                              3 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by gentlebenthebear, Today, 01:30 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by cls71, Today, 04:45 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X