Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleDrawObject convert to OnRender()

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

    SampleDrawObject convert to OnRender()

    Hello,

    Would it be possible for someone to make a replica of the SampleDrawObject indicator, but instead of creating the draw objects in the OnBarUpdate(), to do so within OnRender() using SharpDX, as that would help in learning how to use OnRender().

    Thank you.

    #2
    Hello,

    Thank you for the post.

    I wanted to check, have you seen the SampleCustomRender indicator that comes with NT8?

    I can put in a feature request for an expanded example to be placed in the reference samples as well.

    I look forward to being of further assistance.

    Comment


      #3
      Thanks for the reply Jesse.

      I have reviewed the SampleCustomRender indicator, but like most of the examples I have seen, it deals with placing logos on the chart. I am looking for an example that deals with locating draw objects over specific bars on the chart. I think I have sorted out the Y axis using:
      Code:
      // gets the pixel coordinate of the price value passed to the method
        			int     yByValue = chartScale.GetYByValue(High[0] + 2*TickSize);
      But I am having trouble sorting out the X axis of the bar. Also, how to use the diamond in SharpDX. For example, how would the draw object below that I use in the OnBarUdpate() section be translated if used in OnRender()?
      Code:
      Diamond myDiamondBullB = Draw.Diamond(this, "BullDiamond" + CurrentBar, false, 0, High[0] + 1 * TickSize, Brushes.Green);
      			myDiamondBullB.OutlineBrush = Brushes.Black;

      Comment


        #4
        Originally posted by GeorgeW View Post
        I am having trouble sorting out the X axis of the bar. Also, how to use the diamond in SharpDX. For example, how would the draw object below that I use in the OnBarUdpate() section be translated if used in OnRender()?
        Code:
        Diamond myDiamondBullB = Draw.Diamond(this, "BullDiamond" + CurrentBar, false, 0, High[0] + 1 * TickSize, Brushes.Green);
                    myDiamondBullB.OutlineBrush = Brushes.Black;
        You can get the x-axis position of a bar within the for loop like this:
        Code:
        for (int index = ChartBars.FromIndex; index <= ChartBars.ToIndex; index++) 
        {
            float f_barxpos    = chartControl.GetXByBarIndex(ChartBars, index) ;[COLOR=Green]// X position of specific bar centerline[/COLOR]
        To draw diamonds (or any shape other than rectangles, ellipses or lines) you'll need to use SharpDX.Direct2D1.PathGeometry and SharpDX.Direct2D1.GeometrySink. Take a look at the @ZigZag.cs code and this help guide section:

        Comment


          #5
          Thanks for pointing me in the right direction, tradesmart.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X