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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            57 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            78 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            41 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            101 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            61 views
            0 likes
            Last Post PaulMohn  
            Working...
            X