![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Sep 2008
Posts: 75
Thanks: 0
Thanked 0 times in 0 posts
|
Is it possible to add a horizontal line to an indicator with:
Add(new Line(Color.Gray, SetLevelVar, "whatever")); where it is possible to configure the level in SetLevelVar through the Indicator parameters? Since the Add() function much be called in Initialize() I am not finding how I can change this variable and plot the line at different levels. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
|
I assume you mean you want to change the level dynamically by passing different parameters to your indicator on each bar. Correct?
To change it dynamically, I would write Whatever.value = newvalue; but you need to make sure that there's an entry for "Whatever" in your indicator properties section. For me, an easier way would simply be to use DrawLine(). The first time you call it, it creates a line. The second time you call it with the same identifier, it simply moves the line to the new location you set. -Alex |
|
|
|
|
|
#3 |
|
Member
Join Date: Sep 2008
Posts: 75
Thanks: 0
Thanked 0 times in 0 posts
|
Not quite..
I want to configure horizontal lines in an indicator based on input in the Parameters dialog box. Depending on the instrument I am trading, I may be looking for the oscillator or plot to reach a different level. I want to be able to configure that in the parameters dialog box. From what I have working now, it is not possible to change the level since the Add() function is called in Initialize(). As I type, it does not make sense that I need this in OnBarUpdate(), but the lines are being created in Initialize() and the system throws an error if I try to create the lines in OnBarUpdate(). |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
|
Well, the first time you load an indicator into a chart, the parameters box shows you options for the line levels you want. However, once, set, you can't change them. I tried this in one of my indicators:
(intitialize) Add(upperline = new Line(System.Drawing.Color.Silver, 55, "Upper")); and then I set upperline.Value to some other value and nothing happened. It didn't matter if I set this on every bar in OnBarUpdate() either. As I said before, your best bet is to call DrawLine() in OnBarUpdate like this: DrawLine("MyLine", CurrentBar-1, linevalue, 0, linevalue, Color.Gray, DashStyle.Solid, 1); Linevalue is your parameter. If you call that on every bar, the line should always update its length to span all the bars. -Alex |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Have either of you been able to make a sample of this indicator that the rest of us can test along with you?
Please post and let us know your findings. KZ |
|
|
|
|
|
#6 |
|
Member
Join Date: Sep 2008
Posts: 75
Thanks: 0
Thanked 0 times in 0 posts
|
Not sure I understand your question entirely, but here is what I did to get to a point where I can draw lines in an indicator that have configurable "levels" on the y-axis.
Initialize () { DrawOnPricePanel = false; } OnBarUpdate() { DrawHorizontalLine("TagName", false, AxisLevel, Color.Yellow, DashStyle.Dot, 1); } The only downside to this method is that the lines are selectable and moveable. (or a feature...) :-) |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Indicator: Using custom events to output the current Level II data book | NinjaTrader_Josh | Reference Samples | 0 | 03-04-2008 11:40 AM |
| Level 2 indicator | DrDeath | Indicator Development | 2 | 02-10-2008 06:00 AM |
| Bugs with DrawTextFixed and saving templates with configurable fonts | Wizard | Historical NinjaTrader 6.5 Beta Threads | 4 | 12-12-2007 07:57 AM |
| Configurable Daily Session Start/End times? Pivots? | Drew | Historical NinjaTrader 6.5 Beta Threads | 3 | 12-03-2007 07:03 AM |
| Indicator: Creating your own Level II data book | NinjaTrader_Josh | Reference Samples | 0 | 09-30-2007 10:52 PM |