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

SharpDX to overlay horizontal lines

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

    SharpDX to overlay horizontal lines

    Hi All,

    I would like to know how to get items drawn via SharpDX to overlay horizontal lines. In the graphic below two horizontal lines (green and blue) overlay the SharpDX design at 138 and 58. I experimented a bit with Zorder but it didn't seem to have any effect. The SharpDX rectangle design is being drawn by the code below.

    Thanks !

    Click image for larger version

Name:	20200623_100826_WS2.png
Views:	490
Size:	8.8 KB
ID:	1106379


    SharpDX.RectangleF rect1 = new SharpDX.RectangleF(x - BarWidth, y + barYOffset, BarWidth, BarHeight);
    RenderTarget.FillRectangle(rect1, dxmBrushes["PeripheryBarBrush"].DxBrush);


    #2
    Hello Bidder,

    Are the lines and the rectangle both rendered in the same script in OnRender()?
    Are these coming from different scripts or from a draw method?

    The order objects are rendered within a single script will layer the objects with the first rendered objects on the bottom. Render anything you want on top last.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea, The greenish line is a hand drawn horizontal line and the blueish line is a was drawn using Draw.HorizontalLine() in a totally separate script applied to the same chart.

      Comment


        #4
        Hello Bidder,

        The indicators themselves have the z-order.

        If these are not the same script, then you would need to manually adjust the z-order of the individual objects.

        Click the manually drawn line, hold shift then scroll the scroll wheel up to push this back in the z-order.

        Click the draw line from the other script, hold shift, then scroll the scroll wheel up to push this back in the z-order.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Some other info:

          The script drawing the rectangle (SharpDX.RectangleF) has MediaBrush.Opacity set to 1 which is what I would expect.
          Last edited by Bidder; 06-24-2020, 03:21 PM.

          Comment


            #6
            Hello Bidder,

            Are you talking about an input you have added to the script? You've changed this and clicked OK?

            Are you printing the value of the input to see what is in the script?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea, Thank you for the input.

              Just for anyone reading the thread, below is what was done to mitigate the issue.

              To solve the overwriting issue for lines drawn by a script move indicator writing SharpDX elements after the indicator drawing the lines.

              To solve overwriting for manual lines the code below was added to the OnRender method of the script managing the lines.

              A soon as any kind of line is added to the chart any previously drawn manual line(s) were immediately moved under the SharpDX element. So the code
              below detects when the number of manual lines on the chart changes and draws and removes a transparent line.


              foreach (Gui.NinjaScript.IChartObject thisObject in ChartPanel.ChartObjects)
              {
              if(thisObject is NinjaTrader.NinjaScript.DrawingTools.HorizontalLin e)
              {
              NinjaTrader.NinjaScript.DrawingTools.Line l1 = thisObject as NinjaTrader.NinjaScript.DrawingTools.Line;
              l1.ZOrder=5;
              if (l1.IsUserDrawn) NbrManualLines=NbrManualLines+1;
              }}

              if (NbrManualLines != PrevNbrManualLines)
              {
              tag="Remove" + DateTime.Now.ToString();
              LineObject=Draw.HorizontalLine(this, tag, Close[0]+(TickSize*10), Brushes.Transparent, LineDashStyle, LineThickness);
              RemoveDrawObject(tag);
              ForceRefresh();
              PrevNbrManualLines = NbrManualLines ;
              }

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by r68cervera, Today, 05:29 AM
              0 responses
              2 views
              0 likes
              Last Post r68cervera  
              Started by geddyisodin, Today, 05:20 AM
              0 responses
              3 views
              0 likes
              Last Post geddyisodin  
              Started by JonesJoker, 04-22-2024, 12:23 PM
              6 responses
              35 views
              0 likes
              Last Post JonesJoker  
              Started by GussJ, 03-04-2020, 03:11 PM
              12 responses
              3,239 views
              0 likes
              Last Post Leafcutter  
              Started by AveryFlynn, Today, 04:57 AM
              0 responses
              6 views
              0 likes
              Last Post AveryFlynn  
              Working...
              X