Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.


    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Salahinho99, 05-05-2024, 04:13 AM
    7 responses
    55 views
    0 likes
    Last Post Salahinho99  
    Started by knighty6508, 05-10-2024, 01:20 AM
    4 responses
    26 views
    0 likes
    Last Post knighty6508  
    Started by OllieFeraher, 05-09-2024, 11:14 AM
    6 responses
    19 views
    0 likes
    Last Post OllieFeraher  
    Started by PaulMohn, 05-02-2024, 06:59 PM
    2 responses
    44 views
    0 likes
    Last Post PaulMohn  
    Started by ETFVoyageur, Today, 02:10 AM
    0 responses
    19 views
    0 likes
    Last Post ETFVoyageur  
    Working...
    X