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
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=3419BertrandNinjaTrader Customer Service
-
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
-
Correct, you could use Plots as well...and then don't set values for the time periods where your conditions are not evaluating to true...
For the DrawLine, the idea is to update endBar as the condition is true and stop when false, the sample shows this technique.BertrandNinjaTrader Customer Service
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
-
Kay, for the colors you would need to check into your Plot definitions in the Initialize method.
You could remove the vertical steps by changing the Plot to another style for example Dots.
To stop it from showing, just don't set a value anymore for the plot as your conditions change.BertrandNinjaTrader Customer Service
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.htmlBertrandNinjaTrader Customer Service
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);
}BertrandNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by r68cervera, Today, 05:29 AM
|
0 responses
2 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
3 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
35 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,239 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
6 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Comment