Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Line drawing tool template

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

    Draw.Line drawing tool template

    The NT Beta 8 documentation for Draw.Line lists the parameter templateName for several of the method overloads, for example:

    Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)

    Please advise what is, or where can I find, the correct syntax for that template?

    #2
    Hello,

    This argument is looking for a string representing a user-defined template name. After you have created a template for a specific drawing tool, you can specify the same name in one of the drawing tool method overloads that takes the template name as an argument.

    Thus, if I were to create a Line template named "BlueLineTemplate" I could then pass it in as follows:

    Code:
    Draw.Line(this, "line1", true, 5, High[5], 3, High[3], "BlueLineTemplate");
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Dave View Post
      Thus, if I were to create a Line template named "BlueLineTemplate" I could then pass it in
      Given this, I assume there is a collection of templates (probably their string names) for each draw object. Could you possibly give an example of how I might find these via code? Thanks!


      -=Edge=-
      NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

      Comment


        #4
        It does not appear so. It looks like template names are obtained by reading filenames directly from the appropriate template folder in the Documents folder. In the case of a Drawing Tool, it is reading directly from the NinjaTrader 8/templates/Drawing Tool folder and populating the file names into a temporary cache.

        The best way to determine template names for now will likely be to open the appropriate folder on your PC to view them, rather than trying to access them programmatically.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Originally posted by NinjaTrader_Dave View Post
          It does not appear so. It looks like template names are obtained by reading filenames directly from the appropriate template folder in the Documents folder. In the case of a Drawing Tool, it is reading directly from the NinjaTrader 8/templates/Drawing Tool folder and populating the file names into a temporary cache.

          The best way to determine template names for now will likely be to open the appropriate folder on your PC to view them, rather than trying to access them programmatically.
          Yea, but guess the point was to be able to provide the ability to select and/or change the template via indicator code vs the Draw Object editor..

          I can see a simple work around to this issue for the moment might be to just use the GetTemplateFolder for each drawobject and iterate thru each existing file throwing that into my own list..

          But then I see a problem with this approach as well.. By default, it doesn't look like you create neither a folder nor a Default.xml for every drawobject in the templates folder.. So unless a user were to create a default template themselves, for every single draw object, this doesn't look like a very good solution either..

          Is there a reason that by default you don't create a folder and a default template in the templates folder for each drawobject? And might I suggest you do this in the future?


          -=Edge=-
          NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

          Comment


            #6
            That is a good point. This actually relates to the way that users can create their own default templates. When there is a template named "Default" in the folder, it overrides whatever is specified in State.SetDefaults. This is ideal to allow a user to create their own defaults, but would not be ideal if there were a general default pre-loaded for each.

            Nevertheless, I can definitely see the value in being able to iterate through saved templates in code one way or another, so I will log a suggestion for this item so we can track demand. SFT-661
            Last edited by NinjaTrader_DaveI; 09-10-2015, 01:28 PM.
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Originally posted by NinjaTrader_Dave View Post
              That is a good point. This actually relates to the way that users can create their own default templates. When there is a template named "Default" in the folder, it overrides whatever is specified in State.SetDefaults. This is ideal to allow a user to create their own defaults, but would not be ideal if there were a general default pre-loaded for each.

              Nevertheless, I can definitely see the value in being able to iterate through saved templates in code one way or another, so I will log a suggestion for this item so we can track demand.
              hmmm.. I kinda see your point, but not sure I fully understand.. By default, each drawobject has to use some type of default template you've set up behind the scenes for them. It currently just doesn't happen to be a default.xml file in a drawobjects folder in the template folder. That current behind the scenes template is used until/unless a user creates there own..

              What would be the difference in your current approach, vs just creating this default template as a default.xml file in the appropriate folder to begin with, and then letting the user change/save/overwrite it as default in the future if they so choose?

              Wouldn't either way accomplish the same thing? or am I missing something here?


              -=Edge=-
              NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

              Comment


                #8
                Draw.Line drawing tool template

                The reason I originally asked this question was that I wanted to create an indicator that could be added to one chart and would draw horizontal lines (price levels) globally on all charts of the same instrument. I thought I could do that with the method overload:

                Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)

                by setting isGlobal equal to true. Is that correct? Or is there a better way to accomplish this?

                Further, I was hoping that the Line Template could be defined in my indicator prior to calling the Draw.Line method in the same way a Font can be defined in an indicator prior to calling it in the Draw.Text method. Is that possible? If so, I still need to know the syntax of the Line Template and how to specify it.

                Thanks.

                Comment


                  #9
                  Yes, global = true would draw it on all charts (just like a user setting the drawing property as global).

                  You cannot predine the layout of a template, it would need to be setup through the UI and then you need pass in the name of that template. You could just use "Default" and it'll use whatever is setup as default. If no template exists, it will just render the drawing tools default properties defined in the class.

                  If you don't have a template in mind, you can always just pass an empty string ""
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    Originally posted by -=Edge=- View Post
                    What would be the difference in your current approach, vs just creating this default template as a default.xml file in the appropriate folder to begin with, and then letting the user change/save/overwrite it as default in the future if they so choose?
                    Originally posted by NinjaTrader_Matthew View Post
                    If no template exists, it will just render the drawing tools default properties defined in the class.
                    One reason why the current implementation may be preferable to creating pre-defined default templates is to deal with the possibility that no default template exists. If a user were to accidentally delete that file, for example, or rename it unintentionally, then presumably they would no longer be able to use that drawing tool, if it relied on a pre-existing default template for its property values. In the current implementation, this is not an issue, as the objects will always have property values initialized in the class itself when no default template is present. We could, of course, duplicate the values initialized in the class into an actual template, but that could be a redundant use of resources.
                    Dave I.NinjaTrader Product Management

                    Comment


                      #11
                      Originally posted by NinjaTrader_Dave View Post
                      One reason why the current implementation may be preferable to creating pre-defined default templates is to deal with the possibility that no default template exists. If a user were to accidentally delete that file, for example, or rename it unintentionally, then presumably they would no longer be able to use that drawing tool, if it relied on a pre-existing default template for its property values. In the current implementation, this is not an issue, as the objects will always have property values initialized in the class itself when no default template is present. We could, of course, duplicate the values initialized in the class into an actual template, but that could be a redundant use of resources.
                      Ah.. thanks for the explanation and makes perfect sense now.. I have a couple work around ideas in mind now that Matthew mentioned we can still use "Default" as the template name even though the file and/or folder may not exist.. So I'll continue down that path until you guys possibly provide a better solution..

                      Thanks and sorry for hijacking the thread.. Since you were talking about drawobject templates just seemed like the right place to ask..


                      -=Edge=-
                      NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                      Comment


                        #12
                        Thank you all, NT-Dave, NT-Matthew, and -=Edge=-, for your helpful discussion.

                        Comment


                          #13
                          The problem that I have with the Default Line Drawing Template is that it has a <StartAnchor> and <EndAnchor> defined. This presents problems when you want to draw a new line using the default template.

                          Comment


                            #14
                            That could be an interesting issue. Are you finding that the anchors in the default template override the anchors that you specify when drawing a new line?
                            Dave I.NinjaTrader Product Management

                            Comment


                              #15
                              Yes, the anchors in the default template override the anchors that I specify when drawing a new line. See the following video: http://www.screencast.com/t/8K2FGQjMg

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AaronKoRn, Today, 09:49 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Today, 08:42 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Today, 07:51 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,976 views
                              3 likes
                              Last Post jhudas88  
                              Started by rbeckmann05, Today, 06:48 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post rbeckmann05  
                              Working...
                              X