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 into the future

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

    Draw.Line into the future

    How would I do this please?

    currently this is not working

    Code:
    myLine = Draw.Line(this,"hfdlsfs"+CurrentBar,true,0,Close[0],endtime,Close[0],dotBrush,DashStyleHelper.DashDot,2);
    where endtime = ToTime(11, 59, 00);
    which I think is 1 min before midnight today?

    Also does the following instantiate a line?

    NinjaTrader.NinjaScript.DrawingTools.Line myLine;

    I get one or two random lines so I must be doing something wrong!!

    thanks



    #2
    Hello Mindset,
    No need to instantiate line as you're using Draw.Line, the syntax you need to check as you're using 0 bars for start & time for end which will not work. Also, you need to properly define the endtime parameter as Endtime = DateTime.Parse("23:59", System.Globalization.CultureInfo.InvariantCulture) ; & be sure to add properties -
    [NinjaScriptProperty]
    [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKe y")]
    [Display(Name="Endtime", Order=1, GroupName="Parameters")]
    public DateTime Endtime
    { get; set; }

    You can use Indicator wizard to do this for you, check the correct syntax as attached snapshot.
    Click image for larger version  Name:	Draw Line Syntax.jpg Views:	0 Size:	12.8 KB ID:	1120773
    Hope it helps!

    Comment


      #3
      Hello Mindset,

      Thanks for your post.

      I'd also like to note that if you are appending CurrentBar to the Drawing Tool tag, a new drawing object will be created for each bar.

      As s.kinra mentions, in addition to creating a property for Endtime, you would need to make sure the syntax is correct. I.E. If you are using syntax for Start and and Times, you need to provide DateTimes for both the start and end time. We cannot mix the BarsAgo syntax with the DateTime syntax.

      You can reference the Help Guide for a complete list of overloads to see their syntax, and you can use Intelliprompt to help direct you while writing the code.

      Draw.Line - https://ninjatrader.com/es/support/h...?draw_line.htm

      Intelliprompt - https://ninjatrader.com/support/help...elliprompt.htm

      We look forward to assisting.
      JimNinjaTrader Customer Service

      Comment


        #4
        Thank you. Finally how do I set this so that it will only produce lines for today ( not past days).
        DateTime thisDay = DateTime.Today;
        but I can't seem to put it in an if statement??

        Comment


          #5
          Hello Mindset,
          Are you getting any error ?
          How many lines you want to be plotted ? If you need only one line for today only, remove +CurrentBar from tag.
          Go to Drawing Objects & check if you can see the lines or not.
          Close[0] will be updating for every bar, I think you need to be specific if you need your line to start from the last bar of the day for example, can assign the value in a double variable so it stores only one value at specified bar.
          Normally you see only session timing in the X-axis so 23:59 will not be showing up for previous days, however for today you can scroll or add margin on right to see the line upto 23:59. Try to give a start time manually to check the plot so then you can catch the issue, if any & later can update your code as you need.
          Hope it helps!
          Last edited by s.kinra; 10-05-2020, 03:20 AM. Reason: missed one info

          Comment


            #6
            Hello Mindset,
            I just did a small test code, it plots the last closing price till the end time specified, I kept Calculate = Calculate.OnEachTick; so getting the line moving with every price movement.
            code: Draw.Line(this, "line", true, DateTime.Now, Close[0], End, Close[0], Brushes.AliceBlue, DashStyleHelper.Dot, 1);
            Hope it helps.

            Comment


              #7
              thanks s.kinra

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by renewsaltwater, Today, 01:15 AM
              0 responses
              1 view
              0 likes
              Last Post renewsaltwater  
              Started by cyberpete76, 03-27-2023, 12:29 AM
              6 responses
              262 views
              1 like
              Last Post slightly  
              Started by slightly, Today, 12:49 AM
              0 responses
              2 views
              0 likes
              Last Post slightly  
              Started by sdauteuil, 09-23-2021, 10:16 AM
              4 responses
              1,209 views
              0 likes
              Last Post jacobpescaia44  
              Started by agclub, 04-21-2024, 08:57 PM
              5 responses
              34 views
              0 likes
              Last Post agclub
              by agclub
               
              Working...
              X