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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      156 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      90 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      139 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      130 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X