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

DrawnOnBar for Draw.VerticalLine

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

    DrawnOnBar for Draw.VerticalLine

    Hi Guys,

    how can I use the ChartAnchor Propertie DrawOnBar for a Draw.VerticalLine like the example in the NT HelpGuide?




    Text myText;
    protected override void OnBarUpdate()
    {
    if(CurrentBar == 50)
    myText = Draw.Text(this, "tag", "test", 0, High[0]);

    if(myText != null)
    {
    Print(myText.Anchor.DrawnOnBar); // drawn on bar 50
    }

    }

    Thanks for your support

    #2
    Hello Martin89,

    Thank you for your post.

    VerticalLine has a StartAnchor and an EndAnchor, both of which would be on the same bar. Here's an example of printing the bar a line is drawn on - this indicator will draw a line every 5 bars and print the bar number the line was printed on:

    Code:
     public class ExampleDrawnOnBarVertLine : Indicator
    {
    private int NextBar;
    private VerticalLine MyLine;
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "ExampleDrawnOnBarVertLine";
    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 == 0)
    {
    NextBar = 4;
    }
    if (CurrentBar == NextBar)
    {
    MyLine = Draw.VerticalLine(this, "myLine" + CurrentBar,0, Brushes.Gold);
    Print("Line Drawn on " + MyLine.StartAnchor.DrawnOnBar);
    
    NextBar += 5;
    }
    }
    }
    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DayTradingDEMON, Today, 09:28 AM
    4 responses
    21 views
    0 likes
    Last Post DayTradingDEMON  
    Started by geddyisodin, Yesterday, 05:20 AM
    9 responses
    50 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by George21, Today, 10:07 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by Stanfillirenfro, Today, 07:23 AM
    9 responses
    23 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by navyguy06, Today, 09:28 AM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X