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

Drawing : Fill between 2 vectors

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

    Drawing : Fill between 2 vectors

    Hi Ninja's;

    I'm trying to fill a zone between two vectors with the following function on a custom drawing tool, but, it'doesn't show at all, may you tell me if the function is correct please?
    HTML Code:
    private void FillBands(Vector2 startVector, Vector2 endVector)
      {
          RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
    
    
          SharpDX.Direct2D1.PathGeometry polyGeo = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
          SharpDX.Direct2D1.GeometrySink geoSink = polyGeo.Open();
      
        
          geoSink.BeginFigure(startVector, SharpDX.Direct2D1.FigureBegin.Filled);
          geoSink.SetFillMode(SharpDX.Direct2D1.FillMode.Winding);
    
          geoSink.AddLine(endVector);
          geoSink.EndFigure(SharpDX.Direct2D1.FigureEnd.Open);
          geoSink.Close();
     
          RenderTarget.FillGeometry(polyGeo, areaDeviceBrush.BrushDX);
    
          polyGeo.Dispose();
      }​
    TradeForge
    NinjaTrader Ecosystem Vendor - TradeForge

    #2
    Hello TradeForge,

    Thanks for your post.

    How exactly are the Vector2 objects being defined in the script?

    How are you defining the brush used in the geometry? Are you calling something like the code below?

    SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.DodgerBlue);

    When calling geoSink.EndFigure() I see you are calling FigureEnd.Open. If you change FigureEnd.Open to FigureEnd.Closed, does the behavior persist?

    On the help guide documentation below you could review "SharpDX Lines and Shapes" > "Geometry" sample code for an example of using PathGeometry, GeometrySink, and FillGeometry() to see how these are used:



    You could also view the Ichimoku Cloud indicator from the NinjaTrader Ecosystem User App Share which also demonstrates using SharpDX to fill an area between points.

    Ichimoku Cloud: https://ninjatraderecosystem.com/use...indicator-nt8/


    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Brandon, thank you for your reply, the exemple provided with the indicator works perfectly after a few adaptations
      TradeForge
      NinjaTrader Ecosystem Vendor - TradeForge

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by llanqui, Today, 03:53 AM
      0 responses
      5 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X