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 burtoninlondon, Today, 12:38 AM
    0 responses
    5 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    13 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,982 views
    3 likes
    Last Post jhudas88  
    Working...
    X