Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

chartControl.GetBarPaintWidth(chartControl.BarsArray[0]) doesn't seem to work

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

    chartControl.GetBarPaintWidth(chartControl.BarsArray[0]) doesn't seem to work

    I'm trying to make a dot in OnRender that is the same width as the bars, and shrinks as you zoom in on the chart.

    I have a class level variable I set in OnRender
    HTML Code:
    barWidthP        = chartControl.GetBarPaintWidth(chartControl.BarsArray[0]);

    then I use it in a method
    HTML Code:
    //==================================================================================================            
            private void RenderEntryDot(ChartControl chartControl, ChartScale chartScale,    int x, double center)
            {
                int c1;
                c1                 = chartScale.GetYByValue(center);
                lineStart         = new SharpDX.Vector2(x, c1);
    
                dot = new SharpDX.Direct2D1.Ellipse(lineStart, barWidthP, barWidthP);        
                RenderTarget.FillEllipse(dot, DxBrushWhite);
            }
    ​

    the dot shrinks when I zoom in, but it doesn't appear to be the bar width. What am I dong wrong?

    Click image for larger version

Name:	image.png
Views:	85
Size:	144.9 KB
ID:	1301196

    #2
    Hello cre8able,

    Thank you for your post.

    Is the dot the same width as the bars initially, but not shrinking with the bars? Or is it not the same width from the start?

    To confirm, barWidthP is being calculated in OnRender correct? Where is RenderEntryDot being called?

    I look forward to your response.

    Comment


      #3
      Hey Gaby

      It's not the same width initially. The image shows how wide it is when I load it on the chart.

      It does shrink/grow as I zoom the chart, so it does respond to scaling.

      BarWidthP is called from OnRender

      I also call RenderEntryDot from OnRender.

      I also tried chartControl.Properties.BarDistance but that didn't work either.


      HTML Code:
              protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
              {
                  barWidthP        = chartControl.GetBarPaintWidth(chartControl.BarsArray[0]);
      //            barWidthP        = (int)chartControl.Properties.BarDistance - chartControl.GetBarPaintWidth(chartControl.BarsArray[0]);
                  
                  stagger = 0;        //    set stagger to zero so open gap targets don't move
      //=====    SWING HIGHS            
                  for (int x = SwingHighsClosed.Count - 1; x >= 0 ; x--)
                      RenderSwingHighs(SwingHighsClosed[x].price, SwingHighsClosed[x].startTime, SwingHighsClosed[x].endTime, SwingHighsClosed[x].eqhlCount, chartControl, chartScale);
                  
                  for (int x = SwingHighs.Count - 1; x >= 0 ; x--)
                      RenderSwingHighs(SwingHighs[x].price, SwingHighs[x].startTime, SwingHighs[x].endTime, SwingHighs[x].eqhlCount, chartControl, chartScale);
      //=====    SWING LOWS
                  for (int x = SwingLowsClosed.Count - 1; x >= 0 ; x--)
                      RenderSwingLows(SwingLowsClosed[x].price, SwingLowsClosed[x].startTime, SwingLowsClosed[x].endTime, SwingLowsClosed[x].eqhlCount, chartControl, chartScale);
                  
                  for (int x = SwingLows.Count - 1; x >= 0 ; x--)
                      RenderSwingLows(SwingLows[x].price, SwingLows[x].startTime, SwingLows[x].endTime, SwingLows[x].eqhlCount, chartControl, chartScale);
                  
      //=====    CLOSED BULL GAPS
                  for (int x = BullGapsClosed.Count - 1; x >= 0 ; x--)
                  {            
                      RenderBullFVGsClosed(x, chartControl, chartScale);
                      RenderEntryDot(chartControl, chartScale,chartControl.GetXByTime(BullGapsClosed[x].endTime),  BullGapsClosed[x].entry);
                      if (ShowTargets)                
                          RenderTargets(chartControl, chartScale, chartControl.GetXByTime(BullGapsClosed[x].endTime), BullGapsClosed[x].entry, BullGapsClosed[x].tFixed, BullGapsClosed[x].sFixed, BullGapsClosed[x].be);
                  }
      //=====    CLOSED BEAR GAPS            
                  for (int x = BearGapsClosed.Count - 1; x >= 0 ; x--)
                  {            
                      RenderBearFVGsClosed(x, chartControl, chartScale);
                      RenderEntryDot(chartControl, chartScale,chartControl.GetXByTime(BearGapsClosed[x].endTime),  BearGapsClosed[x].entry);
                      if (ShowTargets)                                
                          RenderTargets(chartControl, chartScale, chartControl.GetXByTime(BearGapsClosed[x].endTime), BearGapsClosed[x].entry, BearGapsClosed[x].tFixed, BearGapsClosed[x].sFixed, BearGapsClosed[x].be);
                  }        
      ​

      Comment


        #4
        Hey Gabby

        when I draw a triangle, it does make it the same width as the bar

        HTML Code:
                private void RenderArrow(ChartControl chartControl, ChartScale chartScale, int x1, int y1, int direction)
                {
            
                    float arrowheadHeight        = (float)(barWidthP);// * 1.5);
                    float arrowheadWidth        = arrowheadHeight / 2;
                    float shaftHeight            = arrowheadHeight * 2;
                    float shaftWidth            = arrowheadHeight / 3;
                        
                    DxVector1 = new SharpDX.Vector2(x1, y1);
                    DxVector2 = new SharpDX.Vector2(x1 + arrowheadWidth * direction, y1 - arrowheadHeight * direction);
                    DxVector3 = new SharpDX.Vector2(x1 - arrowheadWidth * direction, y1 - arrowheadHeight * direction);
                    DxVector4 = new SharpDX.Vector2(x1, y1 - arrowheadHeight * direction);
                    DxVector5 = new SharpDX.Vector2(x1, y1 - shaftHeight * direction);
                                    
                    SharpDX.Direct2D1.Triangle triangle = new SharpDX.Direct2D1.Triangle();
                    triangle.Point1 = DxVector2;
                    triangle.Point2 = DxVector3;
                    triangle.Point3 = DxVector1;
                    SharpDX.Direct2D1.Mesh triangleMesh = new SharpDX.Direct2D1.Mesh(RenderTarget, new SharpDX.Direct2D1.Triangle[] {triangle});
                    
                    RenderTarget.FillMesh(triangleMesh, DxBrushYellow);
                        
                    RenderTarget.DrawLine(DxVector4, DxVector5, DxBrushYellow, shaftWidth);
        
                }
        ​
        ​

        Click image for larger version  Name:	image.png Views:	0 Size:	117.8 KB ID:	1301247
        Last edited by cre8able; 04-27-2024, 08:45 AM.

        Comment


          #5
          Hey Gaby

          Sorry, I just figured it out.

          I thought the parameter for Ellipse was diameter, but its radius so the dot was twice as big as I was expecting. Oops

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X