Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

White Vertical Lines using OnRender()

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

    White Vertical Lines using OnRender()

    Hi

    I'm using OnRender () to create a heat map style chart. Everything works great except for the fact that I'm getting repeating vertical thin white lines. When I use Draw.Rectangle( ) this does not occur. Clearly I'm not quite calculating the draw points for the x axis correctly. Could you please show or email me the code for Draw.Rectangle( ) so I might see how you calculate the x-xis draw points.

    Here's my use of:

    Draw.Rectangle(this,"Box"+CurrentBar+bin,true, 0, y,1,y + stp, Brushes.Transparent, brush, 75);

    Here my calculation of the x-axis within OnRender():

    int yCord = chartScale.GetYByValue(t.Price);
    int yCord2 = chartScale.GetYByValue(t.Price + TickSize);
    x= chartControl.GetXByBarIndex(ChartBars,t.Id);// - (int)(chartControl.BarWidth);


    RenderTarget.FillRectangle(new RectangleF((float)x, yCord2, (float) Math.Abs((float)x - (float)chartControl.GetXByBarIndex(ChartBars,t.Id -1)), (float)Math.Abs(yCord2 - yCord)),brush.ToDxBrush(RenderTarget));

    I see that it is a problem that others have had:

    http://ninjatrader.com/support/forum...ad.php?t=81757

    It's a great frustration and like I said does not occur using Draw.Rectangle( ). I think it would be a great service to the group to show how "statBarsAgo" and "endBarsAgo" are translated into x-axis plotting points.

    Thanks
    Last edited by boreland; 05-29-2016, 04:04 PM.

    #2
    I just wanted to say that I've fixed fixed this problem. The cause of regularly spaced thin vertical white lines is due to the cell width varying by 1 every n calculations. To fix this you have to first detect the white line and then adjust both the start and ends point of the next printing to remove the white line. Here is how I did it:

    //First Calculate the cell width of the first object
    if (idx == ChartBars.FromIndex) cellwidth = Math.Abs(0 - (int)chartControl.GetXByBarIndex(ChartBars,t.Id));

    //Calculated your y coordinates
    int yCord = chartScale.GetYByValue(t.Price);
    int yCord2 = chartScale.GetYByValue(t.Price + TickSize);

    //Calculated your x coordinate start point
    x= chartControl.GetXByBarIndex(ChartBars,t.Id)

    //Set object to be rendered behind the price bars
    SetZOrder(-1);

    //Render object
    RenderTarget.FillRectangle(new RectangleF((float)x - offset, yCord2, (cellwidth + offset), (float)Math.Abs(yCord2 - yCord)),brush.ToDxBrush(RenderTarget));

    //Calculated the print offset for the next object. This is the bit the removes the thin white line by shifting the next object to be displayed to the left.
    offset = Math.Abs((int)x - (int)chartControl.GetXByBarIndex(ChartBars,t.Id -1)) - cellwidth;

    Wallah, not more thin vertical white lines.
    Last edited by boreland; 05-30-2016, 10:22 PM.

    Comment


      #3
      Thank you for your update on this matter.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by LawrenHom, Today, 10:45 PM
      0 responses
      3 views
      0 likes
      Last Post LawrenHom  
      Started by love2code2trade, Yesterday, 01:45 PM
      4 responses
      28 views
      0 likes
      Last Post love2code2trade  
      Started by funk10101, Today, 09:43 PM
      0 responses
      7 views
      0 likes
      Last Post funk10101  
      Started by pkefal, 04-11-2024, 07:39 AM
      11 responses
      37 views
      0 likes
      Last Post jeronymite  
      Started by bill2023, Yesterday, 08:51 AM
      8 responses
      44 views
      0 likes
      Last Post bill2023  
      Working...
      X