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

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
    Paul H.NinjaTrader Customer Service

    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
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Barry Milan, Today, 10:35 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by WeyldFalcon, 12-10-2020, 06:48 PM
        14 responses
        1,428 views
        0 likes
        Last Post Handclap0241  
        Started by DJ888, Yesterday, 06:09 PM
        2 responses
        9 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        40 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Today, 08:51 AM
        2 responses
        16 views
        0 likes
        Last Post bill2023  
        Working...
        X