Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Horizontal Line Plot at level that moves with each bar close

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

    Horizontal Line Plot at level that moves with each bar close

    Support,

    Can you confirm the following would be possible...

    I am looking to plot a horizontal line dynamically at a given plot location... lets assume 50% of the prior bar.

    I know how to get the plot level.

    I don't know how to have the line stretch across the chart and move with price after each bar close and NOT have the plot do the standard functionality of showing the historical plot values.

    I used the following code to print a horizontal line. This works, but I would like to have the value a plot and not a drawing if possible.

    HorizontalLine myLine4 = Draw.HorizontalLine(this, "tag4", High[0] - 100, Brushes.Black); myLine4.Stroke = new Stroke(Brushes.Green, DashStyleHelper.Dash, 1);

    I saw a prior post that provides an example of displaying the SMA value on the current bar only. However I don't know that example would allow a line drawn across the entire chart.

    Any help is greatly appreciated.

    Thanks


    #2
    It is possible. I did something similar to put fibs down based off of the previous candle and it would update on every new candle.

    I have the indicator set to OnPriceChange(), so if you turn the indicator on midbar on a 5m candle, you don't have to wait for a new bar be created before it plots your line.

    The code is as follows:

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1)
    {
    return;
    }
    if (IsFirstTickOfBar)
    {
    double midPoint = (High[1] + Low[1])/2; // This creates a line at the midpoint of the prior candle
    HorizontalLine myLine = Draw.HorizontalLine(this, "tag", midPoint, Brushes.DarkGray, DashStyleHelper.Solid, 1);
    }

    }​

    Comment


      #3
      Hello MattD888,

      If you do not want to use a drawing object and want to use an indicator plot, set the PlotStyle to Horizontal line (either in the Indicators properties window or with the AddPlot() call in State.SetDefaults).
      Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      557 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X