Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Extend or reposition line

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

    Extend or reposition line

    I want to modify the CurrentDayOHL indicator that comes with NJ8 to use a solid line segment. However, regardless of line type, there are vertical sections of the line that run between previous high and new high (for example). Everything is connected.

    Would you please point me to an example that allows an unconnected horizontal line segment to be drawn, and then extended or repositioned as needed.

    For example:

    NinjaTrader.NinjaScript.DrawingTools.Line highLine = Draw.Line(this, "HighLine", false, 0, High[0], -4, High[0], Brushes.Red, DashStyleHelper.Solid, 2);

    gets me started. On the next bar, how do I extend highLine one bar to the right?

    Finally, when the next bar's high exceeds the Y price of my line, how do I reposition the line to the new bar and Y price value? Or must I dispose of the line and just create a new one?

    Many thanks.

    #2
    Hello,

    Thank you for the post.

    You would be correct in the sense everything is connected, this indicator uses Plots to store the values calculated so it is indeed one long continuous series of data. The indicator as it is now would use Plots and one of the effects of the style it uses is to "break" the line rather than plotting between sessions. When the style is changed, the plot can be seen better between sessions.

    I couldn't suggest anything to extend the line past the current bar, negative indexes are not technically supported. I could really only suggest to draw up to the CurrentBar or last bar on the chart which is the 0 BarsAgo index.

    To change the existing lines price, you would need to call its tag name again with the new price, so if the line was named MyLine, just call Draw.Line again using the tag "MyLine" and it would update the existing line. You could set a specific name for each line per session to know you will affect only the most recent line while the price changes.

    To draw use lines in this indicator rather than plots, you could use the existing plot data and add syntax/logic for the Draw.Line where needed. If you need to draw a line from the start of the session to the current bar, that could be like the following syntax:

    Code:
    if(CurrentBar < Bars.BarsSinceNewTradingDay) return;
    Draw.Line(this, "MyLine", Bars.BarsSinceNewTradingDay, Close[Bars.BarsSinceNewTradingDay], 0, Close[0], Brushes.Blue);
    In place of Close[] you could use the series from the indicator in which you want to draw the line for its value.


    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    563 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    329 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
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X