Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Region fill color from property ?

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

    Draw.Region fill color from property ?

    Hey Everyone,

    I have a region that I am shading between two plots. Its working well as long as I hard code the color with Brushes.Red or whatever color I want.

    I tried creating a property called RegionColor as a public Brushes.

    I then also set the default to Brushes.Red or whatever.

    I am getting an error in my code which says cannot implicitly convert type system.windows.media.soliccolorbrush to system.window.media.brushes.

    I don't exactly understand the conversion because I am setting my RegionColor type to Brushes, so when I set it to Brushes.Red as a default, I don't see why the conversion.

    Anyone have any ideas on this one?

    #2
    Hello ErikY,

    From the error it sounds like you have an incorrect type or namespace used somewhere, likely Brushes which should instead be singular or Brush.

    A simple way around this would be to generate the property using the indicator wizard. In the NinjaScript editor, create a new indicator and when the new indicator wizard opens select the user input tab. Define a brush input and click Generate. The resulting code can be copied into your existing script to replace the property that you had. Doing it this way also generates the correct serialization property for saving in templates.


    I look forward to being of further assistance.

    Comment


      #3
      Thanks, this worked! The problem I had was I was setting as Public Brushes and it was supposed to be Public Brush. The wizard set it correctly and I was able to fix it, great tip, thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X