• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Line

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

    Draw Line

    I am trying to draw a line using the following formula (Midpoint). It should start at the beginning of the session and run to current adjusting along the way. I looked at Draw.Line but am getting errors. Any help would be appreciated. Thank you.

    CurrentDayOHLC().CurrentLow[0] + (CurrentDayOHLC().CurrentHigh[0] - CurrentDayOHLC().CurrentLow[0])


    #2
    Hello EthanHunt,

    Thank you for your post.

    I would suggest assigning that calculation to a Plot:

    https://ninjatrader.com/support/help...t8/addplot.htm

    Here's a quick example:

    Code:
            private CurrentDayOHL CurrentDayOHL1;
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Indicator here.";
                    Name                                        = "AddAPlot";
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = true;
                    DisplayInDataBox                            = true;
                    DrawOnPricePanel                            = true;
                    DrawHorizontalGridLines                        = true;
                    DrawVerticalGridLines                        = true;
                    PaintPriceMarkers                            = true;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event. 
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive                    = true;
                    AddPlot(Brushes.Orange, "MyPlot");
                }
                else if (State == State.DataLoaded)
                {
                    CurrentDayOHL1 = CurrentDayOHL();
                }
            }
    
            protected override void OnBarUpdate()
            {
                Value[0] = CurrentDayOHL1.CurrentLow[0] + (CurrentDayOHL1.CurrentHigh[0] - CurrentDayOHL1.CurrentLow[0]);
            }
    
            #region Properties
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> MyPlot
            {
                get { return Values[0]; }
            }
            #endregion
    This will plot this as a line all the way to the current bar, changing as the calculation changes.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks. This appears to be plotting a line at the high of the day only. The calcs look right though...

      Comment


        #4
        Hello EthanHunt,

        Thank you for your reply.

        That would be because I used your calculation, which simply subtracts the low from the high and then adds it again to the high, leaving you with a value equal to the high. You can absolutely adjust the calculation however you like.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          You're correct, I fixed it. Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by oscsoft, Today, 07:07 PM
          0 responses
          5 views
          0 likes
          Last Post oscsoft
          by oscsoft
           
          Started by PanicTrades, Today, 07:01 PM
          0 responses
          12 views
          0 likes
          Last Post PanicTrades  
          Started by dedouglas, Today, 03:38 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by aligator, Today, 03:20 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by aramtrader, Today, 03:05 PM
          2 responses
          17 views
          0 likes
          Last Post aramtrader  
          Working...
          X