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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          161 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          308 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          245 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          349 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          179 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X