Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

B11. Porting NT7 code using Color to NT8 code using Brushes

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

    B11. Porting NT7 code using Color to NT8 code using Brushes

    Hello Support

    I am trying to convert an indicator from NT7 to NT8 and I'm having trouble resolving this piece of code so that it will work with NT8.

    When I use "BarBrushes[0] = Color.FromArgb(alpha, BarBrushes[0]);" in NT8, I get Error: There is argument given that corresponds to the required formal parameter 'g' of 'Color.FromArgb(byte, byte, byte, byte)

    In NT7 the syntax was public static Color FromArgb(int alpha, Color baseColor). I've been googling for over an hour and I can't find an equivalent method for Brushes.

    I need to apply an alpha to the bar brush color to show its an Up bar with close > open.

    Since NT8 uses Brushes and not Color, I don't know how to use Color.FromArgb with Brushes.

    Can you please help me with converting this line of code below in BOLD to NT8 ?

    Thank you


    NT7 Code:
    private Color downColor = Color.Salmon;

    if(Close[0] > Open[0])
    BarColor = Color.FromArgb(alpha, BarColor);
    else
    BarColor = downColor;



    NT8 Code:
    private Brush downColor = Brushes.Salmon;

    if (Close[0] > Open[0])
    BarColor = ?????
    else
    BarBrushes[0] = downColor;

    #2
    Hello,

    Thank you for the question.

    Because you know NT8 uses Brushes and not colors, that can help form your search on google. To locate items for WPF like how to make a brush from ARGB, you would need to search google for something like "How to make a brush from ARGB C#".

    that would result in this page which the second reply is the answer: http://stackoverflow.com/questions/1...rom-a-rgb-code

    Code:
    var brush = new SolidColorBrush(Color.FromArgb(255, (byte)R, (byte)G, (byte)B));
    You could just substitute the "var brush" for the variable in your script or if you are looking for the equivalent to BarColor it is now BarBrush.

    Code:
    BarBrush = new SolidColorBrush(Color.FromArgb(255, 125,30,56));


    Basically most items that were "Color" would now be replaced with "Brush", BarColor is now BarBrush.

    This change can be found on the code breaking changes page: http://ninjatrader.com/support/helpG...ng_changes.htm
    If you search for "BarColor" it shows the new syntax for NT8 next to it.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      Thanks for the help. I used a variant of SolidColorBrush

      byte g = ((Color)BarBrushes[0].GetValue(SolidColorBrush.ColorProperty)).G;
      byte r = ((Color)BarBrushes[0].GetValue(SolidColorBrush.ColorProperty)).R;
      byte b = ((Color)BarBrushes[0].GetValue(SolidColorBrush.ColorProperty)).B;

      BarBrushes[0] = new SolidColorBrush(Color.FromArgb((byte)alpha, r, g, b));

      Comment

      Latest Posts

      Collapse

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