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

Get Draw Line Style, Width & Color From User Inputs

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

    Get Draw Line Style, Width & Color From User Inputs

    Hello,

    My strategy is designed to add horizontal lines to the chart. I would like to assign the Style, Color and Width properties based on user specified values.

    Would appreciate syntax required to access those properties. Thank you!

    To specify, I am wondering if there is a easy, consolidated way to acquire these values or do I have to capture them individually by type?
    Last edited by MercuryScripter; 06-02-2015, 04:44 PM.

    #2
    Hello,

    The Width property would be the simplest one to do this way, since it requires an int. You could simply expose a public int property that the user could enter.

    The Color and Style properties will be a bit different, because these items are enumerated constants (enums). The way I've seen others accomplish this is to peg the enums to integers, then add a sort of key to which number represents which selection in the description of the property. This way, when a user clicks within this property's field when setting up the indicator or strategy, they will see a description that says "1 - Blue, 2 - Red, 3 - Green," etc.

    Then, you can use a switch statement on the exposed property before drawing the line. This would not be the most elegant code design, but it would get the job done. Something like the following:

    switch userColor
    {
    case 1: DrawHorizontalLine(x,x,x,Color.Blue,x,x);
    break;
    case 2: DrawHorizontalLine(x,x,x,Color.Red,x,x);
    break;
    }

    You could do this for both the Color and Style. The links below will show you all of the possible values for these enums:

    https://msdn.microsoft.com/en-us/lib...(v=vs.90).aspx

    https://msdn.microsoft.com/en-us/lib...(v=vs.90).aspx

    And just in case, here is the link for the proper syntax for DrawHorizontalLine().

    http://www.ninjatrader.com/support/h...zontalline.htm

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Hello Dave, thank you again for your response. I have a follow up question. Most indicators have a "Plots" section that enables the user to assign the plot properties. How can I use that property to enable the user to set the properties of the horizontal lines I wish to add to my charts through my strategy? Thank you!

      Comment


        #4
        Hello,

        I've worked up a sample script that will show how the setup I proposed would work (see attached). In this sample, there are exposed integer properties for the line width, color, and dash style, then "switch" and "if" statements are used to draw the line based upon the user's input.

        Also, the information that Michael mentioned in the post below will apply, as well:
        https://www.ninjatrader-helpdesk.com...&reqid=1328623
        Attached Files
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Thank you Dave. Really appreciate your help and diligence!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          4 responses
          20 views
          0 likes
          Last Post alifarahani  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by PhillT, Today, 02:16 PM
          2 responses
          7 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by Kaledus, Today, 01:29 PM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frankthearm, Yesterday, 09:08 AM
          14 responses
          47 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X