![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
How can I code an indicator Line to be dotted by default? By default a line's Dashstyle is a solid line, but I'd like to set it to Dot. I can do this with Plot() and Drawline(), but how can I do this with Line()? I can change the Line style manually in the indicators window, so there must be a way to set this within the indicator code, Thanks, Jeremy |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Try something like this in Initialize() after you call the Add() method for the plot.
Plots[0].Pen.DashStyle = DashStyle.Dash;
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
|
not much luck with getting the dotted lines set up as default
Last edited by duck_CA; 01-19-2008 at 12:02 PM.
Reason: additional pic
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
The following code will work:
Code:
protected override void Initialize()
{
Add(new Plot(Color.Blue, PlotStyle.Line, "DoubleEMA"));
Plots[0].Pen.DashStyle = DashStyle.Dash;
}
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
|
how can i include the values in the script? example would be: a dotted line @ 14230
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
In order for your code to take effect you will need to first remove the indicator from the chart and readd it. This will then replace the Solid dashstyle setting with your new Dash DashStyle.
To have an option as to what value you want your line drawn on you will need to create a user definable variable in your code. Please take a look at the SMA indicator to see how we created a user definable input for the Period. Alternatively, since what you want to do seems to be just draw horizontal lines you may want to try using the ConstantLines indicator that we have provided. You can always change the solid line to a dashed line in the right settings when you are adding the indicator.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
|
thanks guys but i need the "exact" way of doing as i am no tech guy here
![]() is there a way i could just "copy" the formula to a new or blank indicator and move forward. i have spent several hours trying to figure this out with no luck and any help would greatly be appreciated. you can look at the pic i posted above which would show a dotted line that allows me to input a number in the script as well.. example would be: a dotted line @ 12450. i will have about 100 of these lines to do so if i could get it set up through the ninja script, it would make my life easier. keep up the great works people
|
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
See the attached reference sample.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
|
hey ray,
thanks for the zip file. works nicely for the 2 examples you created. can you tell me how formula would look for more than 2? i got an error when adding a additional line set thingy. were closer ![]() thanks |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Unfortunately not, I am already outside the scope of what we provide support for. You will need to open the file and really look at what is happening.
Hints - Look in the Properties Region Look in the Variables Region Try to replicate the lines of code and slight change the names etc...
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to draw a parallel line to a trend line? | tradewiz | Charting | 4 | 12-19-2007 04:42 AM |
| Default Value for EntryHandling | aslane | Strategy Development | 2 | 12-03-2007 07:18 AM |
| Default ATM Strategy | vlc | Suggestions And Feedback | 5 | 10-01-2007 05:55 AM |
| Default Time Intervals | biggo | Charting | 4 | 07-12-2007 12:04 AM |
| Line "names" in Indicator Box change to "Line" after modification | higler | Charting | 3 | 05-02-2007 06:05 AM |