Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using decimals for a drawing object

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

    Using decimals for a drawing object

    Currently I am using
    DrawLine("VerticalUp", false, -right1, (EMA(BarsArray[1],13))[0], -right1, (LinReg(BarsArray[1],4))[0], Color.Green, DashStyle.Solid, 2);
    to draw a vertical line further to the right in the chart. The "-right1" in the properties looks like this.

    [Description("Moves the vertical line further to the right.")]
    [GridCategory("EMA lengths")]
    public int Right1
    {
    get { return right1; }
    set { right1 = Math.Max(1, value); }
    }
    That works nicely.

    Now my question: Is there a possibility to amend how far I want to move it by decimals? I tried this

    [Description("Moves it to the right.")]
    [GridCategory("EMA lengths")]
    public int Right14
    {
    get { return right14; }
    set { right14 = Math.Max(0.01, value); }
    }
    but that does not work. I also tried putting into Variables:
    private double right14 = 1.5; and then into Properties

    [Description("Moves it to the right.")]
    [GridCategory("EMA lengths")]
    public double Right14
    {
    get { return right14; }
    set { right14 = Math.Max(0.01, value); }
    }
    but still no go.

    Is there a possibility to make it work or is this not supported in NT?
    sandman

    #2
    Hello sandman,

    Thanks for your post.

    In your example -right1 is in the start bars ago and end bars ago sequence of the method overload for Draw.Line(). As advised in the helpguide these would be integer values.

    Alternatively, you can use the method overload that allows for the start bar and end bar to be replaced by time/time structures.

    This would be applicable to all draw method.

    Reference: https://ninjatrader.com/support/help...?draw_line.htm

    Comment


      #3
      Paul.
      Thanks. Yes, I had read the Help guide already and noted the use of integer values. That is why I asked if there is a way to make it work with decimals. (Note that I am using NT7 not NT8.)

      Your mention to use a time structure for startBarsAgo and endBarsAgo sounds interesting. Could you show me how to do that, perhaps using the Help guide example as I have no clue how to go about doing that:

      NT8:
      Draw.Line(this,"tag1",false,10,1000,0,1001,Brushes.LimeGreen,DashStyleHelper.Dot,2);

      NT7:
      DrawLine("tag1", false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Dot, 2);

      sandman

      Comment


        #4
        Hello sandman,

        Thanks for your reply.

        Sorry about the NT8 reference.

        Here is a quick NT7 test code segment you can test out:

        #region Variables
        private bool doitonce = true;
        #endregion
        protected override void Initialize()
        {
        Overlay = true;
        }
        protected override void OnBarUpdate()
        {
        if (Historical) return; // real time test
        if (doitonce)
        {
        DrawVerticalLine("A", Time[0], Color.Blue, DashStyle.Solid, 3);
        DrawVerticalLine("B", Time[0].AddMinutes(5), Color.Red, DashStyle.Solid, 3);
        doitonce = false;
        }
        }


        Add it to a 1 minute chart. when the current bar closes it will draw a blue line at the bar and it will draw a red line 5 bars in the future. The bool doitonce is so that it does it just the one time.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X