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

Draw Line from the chart first bar

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

    Draw Line from the chart first bar

    Hello,

    I'm trying to draw a line which starts on the open of the first bar of the chart and extends to the actual bar.
    Same thing I'd like to do for any session, looking at the previous bar close and extend it to the actual bar.

    Are there any example to do it or anyone could give me a hint?

    Thanks.

    #2
    Max, the code for drawing a line is as follows:
    Code:
    DrawLine(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color);
    As for your specific application, please try this:
    Code:
    DrawLine("my line", CurrentBar, Open[CurrentBar], 0, Close[0], Color.Blue);
    AustinNinjaTrader Customer Service

    Comment


      #3
      Draw Line from Open High and Low to end of day

      Hello,
      I would like to:
      1) Draw Line from Opening bar High and Low, to end of day.

      2) Draw Line from a specific bar ( Say 10:00 am) High and Low, to end of day

      Thanks for the help.

      Comment


        #4
        Hello,
        I have attached a sample I have made on how to do this.
        To Import the Sample

        Download the NinjaScripts to your desktop, keep them in the compressed .zip file.

        From the Control Center window select the menu File> Utilities> Import NinjaScript

        Select the downloaded .zip file

        NinjaTrader will then confirm if the import has been successful.

        Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

        Once installed, you may add the indicator to a chart by:

        Right click you chart > indicators > Select the Indicator from the list on the left > New > OK
        Please let me know if you have any questions on the sample.
        Attached Files
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          Draw line

          Thanks NinjaTrader_CodyB!!! that was great. There are 2 things I would like to do, if not too hard. I would like the lines to be thicker, but most of all, is there a way I could add a line of code to allow me to look back 5,10,20 days?

          Thanks again. This was a big help to me.

          Comment


            #6
            Hello,
            Thank you for your reply.
            You can increase the width of the drawing tools by changing the DrawLine methods to the following format and increase the integer for width.
            DrawLine(string tag, bool autoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color, DashStyle dashStyle, int width)

            We can have the lines plot with every session by writing the tags for the lines as unique tags.

            For convenience I have updated my sample and attached the updated Sample. Before importing this version you will need to delete the previous sample. To delete it you will go to Tools> Edit NinjaScript> Indicator> Select the Indicator > Press Delete. Once removed you can import the indicator attached.
            Attached Files
            Cody B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by frankthearm, Today, 09:08 AM
            7 responses
            30 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by NRITV, Today, 01:15 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by maybeimnotrader, Yesterday, 05:46 PM
            5 responses
            25 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by quantismo, Yesterday, 05:13 PM
            2 responses
            18 views
            0 likes
            Last Post quantismo  
            Started by adeelshahzad, Today, 03:54 AM
            5 responses
            33 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X