Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Applying Opacity in the code

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

    Applying Opacity in the code

    Hi,

    One of fellow members shared an indicator and I'm trying to add opacity inside this code. But I have no idea how... I want 50% of opacity of this vertical line. I would appreciate any suggestion. Thank you

    protected override void OnBarUpdate()
    {
    if (Time[0].TimeOfDay.Minutes == 0 && (Time[0].TimeOfDay.Seconds == 00 ))
    {

    VerticalLine myLine1 = Draw.VerticalLine(this, "LineOnStart"+Time[0], 0, Brushes.White);
    myLine1.Stroke = new Stroke(Brushes.DimGray, DashStyleHelper.Dot, 1);

    }



    #2
    Hello jjanguda,

    Thanks for your post.

    What I would suggest is to create a private brush variable at the class level, for example: private Brush myBrush = Brushes.DimGray;

    To create the custom brush once, in State.DataLoaded:

    Brush temp = myBrush.Clone(); // copy current brush
    temp.Opacity = 50.0/100.0; // 50% opacity
    temp.Freeze(); // required to freeze
    myBrush = temp; // assign 50% opaque brush to user brush.


    In OnBarUpdate() you would use myBrush where you are currently specifying a brush.

    Note: The brush is created in state data loaded so that it is only created once.


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    72 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    152 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