Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How can I draw a line which extends with
Collapse
X
-
Kay, a simple example of how to achieve this can be found in the second part of this sample - http://www.ninjatrader-support2.com/...ead.php?t=3419
-
Hi Bertrand,
The problem with DrawLine is that I need an endbar. The line can't extend/update as and when a new bar is formed/completed.
Some have suggested using the Plot function but I am not sure how to stop the line from extending if certain conditions are fulfilled for either function....
Comment
-
If (!Condition)
{
DrawLine("Line", int StartBarsAgo, int Start y, 0, int End y, Color.color);
}
This will always draw a line to the current bar.
Comment
-
Hi Bertrand,
I added these 2 lines
if ((Close[0] <= doubleY) && (doubleY >0))
{
AvgR.Set(doubleY);
}
PLUS
public DataSeries AvgR
{
get { return Values[0]; }
}
under properties.
The result: An orange line.
1) How did I get an orange line? I have not selected "orange" as a color in my code.
2) How can I change it to green?
3) Instead of a Solid line, can I get a Dash line?
4) Ideally I can get the line to stop printing once is greater than doubleY and recommence when a new 9 is completed...Last edited by kaywai; 03-02-2010, 01:43 AM.
Comment
-
Bertrand,
1) Aside from the DataSeries, I didn't even add anything to the initialize method. Definitely nothing to do with plots. I've attached the code fyi.
2) How do I assign a zero value to the plot as conditions change?Attached Files
Comment
-
I see, this is just the default color when nothing is assigned as in your case...please add to the Initialize() as per this link to be able to control visualizations for this - http://www.ninjatrader-support.com/H...eV6/Plots.html
You could just call the Reset method for the underlying dataseries or don't set a value at all - http://www.ninjatrader-support.com/H...iesObject.html
Comment
-
Hi Bertrand, Regarding the DataSeries.Reset(), I tried this:-
if ((Close[0]< doubleY) && (doubleY >0))
{
Plots[0].Pen = new Pen(Color.Green, 2);
Plots[0].Pen.DashStyle = DashStyle.Dash;
AvgR.Set(doubleY);
}
elseif ((Close[0]> doubleY) && (doubleY >0))
{
AvgR.Reset(doubleY); <== 2 error messages
}
I got 2 errors:-
1) CS1502: The best overloaded method match for "NinjaTrader.Data.DataSeries.Reset(int) has some invlaid arguments.
2) CS1503: Argument '1': cannot convert from 'double' to 'int'.
Not sure what I am doing wrong. Please help.
BTW. I fixed the plot line color and dashstyle. Thx!
Comment
-
Yes, this is expected as you set the value to 'null' == empty for plotting purposes - I don't follow why you need this, just use this part only, setting a value for the dataseries to plot when you condition is true -
if ((Close[0]< doubleY) && (doubleY >0))
{
Plots[0].Pen = new Pen(Color.Green, 2);
Plots[0].Pen.DashStyle = DashStyle.Dash;
AvgR.Set(doubleY);
}
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment