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 charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            68 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            150 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            162 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            100 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            288 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X