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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          245 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          157 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          165 views
          1 like
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          250 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          201 views
          0 likes
          Last Post CarlTrading  
          Working...
          X