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!
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
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.Emily C.NinjaTrader Customer Service
-
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:
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);
Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Haiasi, 04-25-2024, 06:53 PM
|
2 responses
17 views
0 likes
|
Last Post
by Massinisa
Today, 05:32 AM
|
||
Started by Creamers, Today, 05:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Creamers
Today, 05:32 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
12 responses
1,786 views
0 likes
|
Last Post
by Leafcutter
Today, 05:30 AM
|
||
Started by poplagelu, Today, 05:00 AM
|
0 responses
3 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
||
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,408 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
Comment