Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

QUESTION: AddPlot Stroke Brushes colors and SharpDX.Color

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

    QUESTION: AddPlot Stroke Brushes colors and SharpDX.Color

    Hi,

    while trying to translate for NT8

    Code:
    Add(new Plot(Color.Blue, PlotStyle.Line, "MyPlot"));
    I'm suggested from https://ninjatrader.com/support/help...ml?addplot.htm to write:
    Code:
    AddPlot(new NinjaTrader.Gui.Stroke(System.Windows.Media.Brushe s.Blue), PlotStyle.Line, "MyPlot");
    ​​at the same time in the example file Custom\Indicators\@SampleCustomRender.cs we learn that to create a brush from System.Windows.Media.Brushes,
    like is done over there,
    Code:
    AreaBrush = System.Windows.Media.Brushes.DodgerBlue;
    ...
    areaBrushDx = areaBrush.ToDxBrush(RenderTarget);
    is less efficient than creating it directly from SharpDX
    Code:
    SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.DodgerBlue);

    so at this point I would expect the following code to be working and be more efficient

    Code:
    AddPlot(new NinjaTrader.Gui.Stroke(System.Windows.Media.Brushe s.Blue), PlotStyle.Line, "MyPlot");
    ​
    But this doesn't compile. with error message:
    Argument 1: cannot convert from 'SharpDX.Color' to 'NinjaTrader.Gui.Stroke',CS1503
    Am I running into some sort of confusion, could you please clarify me?
    Thank you

    #2
    Hello giogio1,

    A SharpDX brush can only be used in the context of OnRender() and cannot be used in other methods like OnStateChange().

    However, are you sure that line of code is what is causing an issue?
    System.Windows.Media.Brushes.Blue is not a SharpDX brush.

    A screenshot of the error message and line referred to in the error message may be helpful.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you. I believe you answered me.


      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by sjsj2732, Today, 04:31 AM
      0 responses
      20 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      280 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      279 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      130 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      90 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X