Announcement

Collapse
No announcement yet.

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
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    54 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    72 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    38 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    99 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    60 views
    0 likes
    Last Post PaulMohn  
    Working...
    X