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

Set vertical line width and opacity

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

    Set vertical line width and opacity

    How do I set the width of the verticalline and it's opacity? the indicator looks like this right now
    Code:
                if (State == State.SetDefaults)
                {
                         SetZOrder(-1);
                    Description                                    = @"Enter the description for your new custom Indicator here.";
                    Name                                        = "My3VerticalLines";
                    Calculate                                    = Calculate.OnBarClose;
                    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;
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (CurrentBar < 52) return;
                
                
                 Draw.VerticalLine(this, "line1", 0, false, "Line1");​
    Last edited by johntraderuser2; 02-24-2024, 12:36 PM.

    #2
    Hello johntraderuser2,

    Thanks for your post.

    To set the width of the the vertical line being drawn, you would need to use one of the Draw.VerticalLine() method overloads that allow you to specify the width property.

    Draw.VerticalLine(NinjaScriptBase owner, string tag, DateTime time, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel)

    Draw.VerticalLine(NinjaScriptBase owner, string tag, int barsAgo, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel)


    See this help guide page for more information about Draw.VerticalLine(): https://ninjatrader.com/support/help...rticalline.htm

    A custom brush would need to be created to control Opacity (alpha value). Instead of using one of the pre-built brushes (Brushes.Red, Brushes.Blue, etc), you could create a SolidColorBrush employing the Color.FromArgb() method, the first value is the "alpha".

    See the help guide page below for more information and examples about working with custom brushes.

    Understanding Custom Brushes: https://ninjatrader.com/support/help...gcustombrushes
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by lightsun47, Today, 03:51 PM
    0 responses
    5 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    10 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    46 views
    0 likes
    Last Post futtrader  
    Started by Option Whisperer, Today, 09:55 AM
    1 response
    14 views
    0 likes
    Last Post bltdavid  
    Started by port119, Today, 02:43 PM
    0 responses
    10 views
    0 likes
    Last Post port119
    by port119
     
    Working...
    X