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 adeelshahzad, Today, 03:54 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by stafe, 04-15-2024, 08:34 PM
      7 responses
      32 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by merzo, 06-25-2023, 02:19 AM
      10 responses
      823 views
      1 like
      Last Post NinjaTrader_ChristopherJ  
      Started by frankthearm, Today, 09:08 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      43 views
      0 likes
      Last Post jeronymite  
      Working...
      X