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

DrawLine -- Please Keep It Simple as I am Stupid

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

    DrawLine -- Please Keep It Simple as I am Stupid

    I have looked at several examples and find myself more and more confused. I am trying to understand the DrawLine function and I want to start with a simple idea like this: Draw a line 10 ticks above the close of the current bar and do this for every bar. Please do not point me to NT help on DrawLine. The example below

    // Draws a dotted lime green line from 10 bars back to the current bar
    // with a width of 2 pixels
    DrawLine("tag1", false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Dot, 2);

    did nothing for me. Question the 1000 and 1001 above represent 10:00am and 10:01am; if so, I do not want my lines to be limited by time of day...I want them to draw a hash marks, not as a plot line (which I do understand somewhat). I tried changing false to true on the auto scale, deleting the 1000, 1001 thinking they were time references and the error came back that I did not have enough conditions to make the code work.

    I know it's basic but I am stuck and frustrated. Any help or examples/modifications are appreciated.

    #2
    Originally posted by sarasotavince View Post
    I have looked at several examples and find myself more and more confused. I am trying to understand the DrawLine function and I want to start with a simple idea like this: Draw a line 10 ticks above the close of the current bar and do this for every bar. Please do not point me to NT help on DrawLine. The example below

    // Draws a dotted lime green line from 10 bars back to the current bar
    // with a width of 2 pixels
    DrawLine("tag1", false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Dot, 2);

    did nothing for me. Question the 1000 and 1001 above represent 10:00am and 10:01am; if so, I do not want my lines to be limited by time of day...I want them to draw a hash marks, not as a plot line (which I do understand somewhat). I tried changing false to true on the auto scale, deleting the 1000, 1001 thinking they were time references and the error came back that I did not have enough conditions to make the code work.

    I know it's basic but I am stuck and frustrated. Any help or examples/modifications are appreciated.
    Code:
    DrawLine("tag1"+CurrentBar.ToString(), false, 1, Close[0]+TickSize*10, -1, Close[0]+TickSize*10, Color.LimeGreen, DashStyle.Solid, 2);

    Comment


      #3
      Hello sarasotavince,

      Thank you for your post.

      Koganam's example provides drawing the line 1 bar back and one bar ahead, 10 ticks above the current price (or last close). This syntax would be viewed as the following: DrawLine(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)

      The syntax above is viewed in the Help Guide section for DrawLine(), I recommend taking a look at the syntax available for the methods and properties you wish to use as they can be multiples.

      The use of CurrentBar ensures that this is drawn on each bar and does not remove the previous DrawLine() in the process.

      For information on CurrentBar please visit the following link: http://www.ninjatrader.com/support/h...currentbar.htm

      Please let me know if I may be of further assistance.

      Comment


        #4
        Thanks koganam,

        Now that I actually have lines on my chart and I experiment. I will also need to investigate the toString() piece...that is new to me also.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by George21, Today, 10:07 AM
        0 responses
        2 views
        0 likes
        Last Post George21  
        Started by Stanfillirenfro, Today, 07:23 AM
        8 responses
        23 views
        0 likes
        Last Post Stanfillirenfro  
        Started by DayTradingDEMON, Today, 09:28 AM
        2 responses
        15 views
        0 likes
        Last Post DayTradingDEMON  
        Started by navyguy06, Today, 09:28 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        8 responses
        32 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X