Announcement

Collapse
No announcement yet.

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?

    https://ninjatrader.com/de/support/h...rawingtool.htm


    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 timmbbo, Yesterday, 10:27 PM
    1 response
    5 views
    0 likes
    Last Post tgn55
    by tgn55
     
    Started by zacharydw00, Yesterday, 11:13 PM
    0 responses
    2 views
    0 likes
    Last Post zacharydw00  
    Started by luxurious_04, Yesterday, 10:55 PM
    0 responses
    1 view
    0 likes
    Last Post luxurious_04  
    Started by 7robert, Yesterday, 07:48 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by saltminer, Yesterday, 06:32 PM
    0 responses
    6 views
    0 likes
    Last Post saltminer  
    Working...
    X