Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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 techgetgame, Yesterday, 11:42 PM
          0 responses
          8 views
          0 likes
          Last Post techgetgame  
          Started by sephichapdson, Yesterday, 11:36 PM
          0 responses
          2 views
          0 likes
          Last Post sephichapdson  
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,613 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Yesterday, 05:56 PM
          0 responses
          10 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          20 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X