Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop rendering anything after the custom margin

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

    Stop rendering anything after the custom margin

    Hi,

    Currently I am using below
    ChartControl.Properties.BarMarginRight = 100;
    for right margin, but I am rending by

    RenderTarget.DrawLine(start.ToVector2(), end.ToVector2(), DXBrush, 2);

    but if I scroll the chart to left, it keeps plotting the line even after the current bar. how can I stop that plotting the current bar?

    second, i am also rendering below line on the same script by

    public double EndPrice;
    kvp.Value.EndPrice = chartScale.GetValueByY(extPoint.ToVector2().Y);
    Point endPt = new Point();
    endPt.X = chartControl.GetXByBarIndex(ChartBars, CurrentBars[0]);
    endPt.Y = chartScale.GetYByValue(kvp.Value.EndPrice);

    RenderTarget.DrawLine(startAdj.ToVector2(), endPt.ToVector2(), Other.BrushDX, Other.Width, Other.StrokeStyle);

    for this line, it does not plot to the right of margin, but it its right end moves ie, it does not stays at the same point, thus it overlaps candles on chart. I want to keep it on the same place regardless, if I scroll left.
    Any help will be appreciated.

    #2
    Hello asmmbillah,

    You can set the end vector2 to the x position of the CurrentBar or the original x value, whichever is smaller (Math.Min()).

    For the moving line, use static x and y values instead of values that come from a bar.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      For the moving line, use static x and y values instead of values that come from a bar.
      Can you please explain a bit further about the above suggestion?

      Comment


        #4
        Hello asmmbillah,

        However you are calculating the end variable (end.ToVector2()) you could assign the x value to be whichever is smaller, the value you chose, or the x value from CurrentBar.

        end.X = Math.Min(myCalculatedValue, chartControl.GetXByBarIndex(CurrentBar));

        For static values on the endPt, just don't convert these from a bar.

        endPt.X = 100;
        endPt.Y = 100;

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks fo your reply. But the problem I am facing following that, how can I then stop the rendering on current bar for the 2nd line from the above example?

          Comment


            #6
            Hello asmmbillah,

            By stop rendering you mean you want the end x point of a line to end at the last bar on the chart, is this correct?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Yes. That is correct.

              Comment


                #8
                Hello asmmbillah,

                This is Jim, responding on behalf of Chelsea who is out of the office at this time.

                You can get the X coordinate from ChartBars.ToIndex if the that is the right most bar.

                For example, you could do the following to extend to the right side of the chart panel or to the last bar on the chart if the last bar is visible.

                BarsArray[0].Count-1 == ChartBars.ToIndex ? ChartControl.GetXByBarIndex(ChartBars, ChartBars.ToIndex) : ChartPanel.W

                We look forward to assisting.

                Comment


                  #9
                  thanks, that solves the problem

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  672 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  379 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  111 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  577 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  582 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X