Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to add Opacity (%) to indicators

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

    How to add Opacity (%) to indicators

    Hi,
    I have an indicator I'm attempting to add the "Plots" Opacity (%) option
    I saw somewhere on here to add Plots[0].Opacity = opacity; to the script but could not figure out where to add it in the script
    I'm thinking it's something simple but I'm unsure how to proceed.

    Your assistance is greatly appreciated
    Attached Files

    #2
    Hi torento, thanks for posting.

    You can set the opacity after calling AddPlot within the OnStateChanged method in State.SetDefaults.

    Kind regards.

    Comment


      #3
      Hi Chris,
      Thanks for your reply
      No matter how I add it in I receive the error "The name opacity does not exist in the current context"
      I am new to editing NinjaScript, but every time I add "Opacity" I receive the message
      Could you please kindly let me know how the line would read so I could add it in without errors,

      Best Regards.

      Comment


        #4
        Hi torento, I took a look at the script you posted and it need to set up custom Brushes with an Alpha property because these are the brushes being used in OnBarUpdate. Here is the OnStateChanged method of that script:
        Code:
        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        Description = @"Enter the description for your new custom Indicator here.";
        Name = "EMASlopeColor2";
        Calculate = Calculate.OnPriceChange;
        IsOverlay = true;
        DisplayInDataBox = true;
        DrawOnPricePanel = true;
        DrawHorizontalGridLines = true;
        DrawVerticalGridLines = true;
        PaintPriceMarkers = true;
        ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
        //Disable this property if your indicator requires custom values that cumulate with each new market data event.
        //See Help Guide for additional information.
        IsSuspendedWhileInactive = true;
        Period = 21;
        [B]UpTrend = new SolidColorBrush(Color.FromArgb(250, 0, 0, 250));
        DownTrend = new SolidColorBrush(Color.FromArgb(250, 250, 0, 0));[/B]
        AddPlot(Brushes.Red, "EMAPLOT");
        }
        else if (State == State.Configure)
        {
        }
        }
        Kind regards,
        -ChrisL

        Comment


          #5
          Hi Chris,
          I very much appreciate your time & assistance
          OK, I figured it out by looking at the NT8 Support Guide "Using Color Pickers"



          So I change the values of the first 2 letters after the # under "Parameters" color to change the opacity now
          I guess #FA must be Full Opacity where in my screenshot I've changed it to #80 for 50%

          Is there a list of all the color codes for use in NT8

          Again Thank you for your assistance.
          Attached Files

          Comment


            #6
            Hi torento, this is coming directly from C#, see the documentation on the FromARGB method:
            https://docs.microsoft.com/en-us/dot...b?view=net-6.0 (publicly available)

            Kind regards,
            -ChrisL

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            637 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            572 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X