Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
lightning until the first touch
Collapse
X
-
Hello franatas,
Thank you for your post.
It appears you have made a statement about drawing a line. Do you have a question about drawing a line that remains on the chart until a certain price is reached? If so, please provide more details and let us know what you might have questions about so we may understand your inquiry and assist you accurately.
Thank you for using NinjaTrader.
-
Hello franatas,
Thank you for your reply.
You could use the Draw.Line() method which allows you to set the startBarsAgo and endBarsAgo values. What you would do is save the bar that you want the line to start on into a variable in order to calculate your startBarsAgo, and you would update the endBarsAgo to a variable that holds the bar where the candle touches the desired price. For example, here is a pseudo-code snippet that demonstrates this idea:
Please let us know if we may be of further assistance.Code:private int startBarIndex, endBarIndex, lineStartBarsAgo, lineEndBarsAgo; private bool priceTouched; if ( // condition that triggers the line to start) { startBarIndex = CurentBar; } // if price is not touched yet, update endBarIndex to CurrentBar if (priceTouched == false) endBarIndex = CurrentBar; // check if the price has been touched. If so, save the CurrentBar index to endBarIndex and toggle the bool to true so endBarIndex is no longer updated if (priceTouched == false && Close[0] // == or >= or <= comparison to desired target price to touch) { endBarIndex = CurrentBar; priceTouched = true; } lineStartBarsAgo = CurrentBar - startBarIndex; lineEndBarsAgo = CurrentBar - endBarIndex; // using the following syntax, we will draw the line Draw.Line(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush) // use whichever startPrice, endPrice, and brush that you'd like, this is just an example Draw.Line(this, "myLine", lineStartBarsAgo, startPrice, lineEndBarsAgo, endPrice, Brushes.Blue);
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
602 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
559 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
559 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment