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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    77 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X