NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 08-01-2007, 12:44 PM   #1
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default Draw Horizontal Lines

I am trying to write an indicator which allows one to set a High and Low, calculate mid and quarter points, then to draw horizontal lines across the price chart. Ideally, these would be yellow dotted lines of width 3.

The code compiles and is very similar to another indicator I have written to draw horizontal lines which does work, but this one does not draw the lines. Maybe my math is messing it up?

FYI, I have very much appreciated your help and have coded some very nice indicators. The ability to do this has made me very excited about NinjaTrader charts.

Thanks again.
Attached Files
File Type: cs vWIBLines.cs (5.9 KB, 16 views)
Richard Von is offline  
Reply With Quote
Old 08-01-2007, 01:09 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

I can't see at a quick glance what could be wrong. Please check your Log tab for any errors. Apart from that, you will have to debug it.
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-01-2007, 01:19 PM   #3
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

What you want to do is use DrawHorizontalLine() instead of the Add(new Line) stuff. The Add(new Line) will not update to changes in your parameters because it is only run once in the Initialize() section.

Check out the attachment. Hopefully that's what you wanted.
Attached Files
File Type: cs vWIBLines.cs (6.1 KB, 30 views)
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-01-2007, 02:22 PM   #4
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for your help. The revised indicator is not working for me.

1. It does not seem to draw the lines.
2. When I change the High and Low settings, the settings for the mid and quarters do not change.
3. When I apply this to a chart, it makes the horizontal grid lines and some other indicators disappear.

Not sure what it's doing. I thought maybe I just had too many indicators on one chart and tried it on a simpler one, but acted the same.

By the way, there were no errors in my Log file.
Richard Von is offline  
Reply With Quote
Old 08-01-2007, 02:30 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

I'm not sure what you mean the settings aren't changing. The mid and qtr are recalculated on every bar. The lines should draw fine. Try this indicator by itself. I suspect it is one of your other indicators causing plotting issues.

Also realize that if your stock price is nowhere near 800 or 750 (your default high and low settings) you simply won't see the lines because your y-axis is out of range.
Last edited by NinjaTrader_Josh; 08-01-2007 at 03:03 PM.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-01-2007, 03:15 PM   #6
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default

Sorry to be dense, but I can't make it work.

I tried putting it on a new chart with only the price bars on it, no lines. I compressed the y axis to check the default regions, but still nothing there.

I added

if (CurrentBar < 2)
return;

to the logic. The choices when you edit the indicator changed to eliminate the qtrs, mid, but still no lines.

I can't figure it out.

Do they show up on your charts?
Richard Von is offline  
Reply With Quote
Old 08-01-2007, 03:52 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

I believe we are on different wavelengths Richard. Let me just touch base with you. Are you currently using the exact indicator I posted or did you take the code and modify it to your likings? If you are using the exact indicator they should draw the lines for you. It does draw on my charts. If you are using your own please post it so I can get an idea of what is going on.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-01-2007, 03:57 PM   #8
Gumphrie
Senior Member
 
Join Date: Jun 2007
Posts: 218
Thanks: 0
Thanked 1 time in 1 post
Default

One possible reason:

If you're using draw objects and you've set 'Overlay' to false you should also be setting 'DrawOnPricePanel' to false in Initialize().


Also make sure you're calling DrawLine in OnBarUpdate()
Gumphrie is offline  
Reply With Quote
Old 08-02-2007, 06:21 AM   #9
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default

I am using the code you sent without modifications on a new chart that only has price candles and still no lines. I condensed the y scale to check the levels, but no lines.

????
Richard Von is offline  
Reply With Quote
Old 08-02-2007, 06:36 AM   #10
Gumphrie
Senior Member
 
Join Date: Jun 2007
Posts: 218
Thanks: 0
Thanked 1 time in 1 post
Default

Not sure what its trying to do but the high and low values are set to 800 and 750, so you need to change those to match the price scale on your chart. Or make it dynamic like adding this to the start of OnBarUpdate :

Code:
high=High[0];
low=Low[0];
Gumphrie is offline  
Reply With Quote
Old 08-02-2007, 12:12 PM   #11
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks to everyone for helping. I found out I could save a standard indicator ConstantLines under a new name and add my logic to that which I now have working.

I appreciate you all working on my problem.
Richard Von is offline  
Reply With Quote
Old 08-02-2007, 12:23 PM   #12
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

That's great!
NinjaTrader_Ray is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Draw line segments PepeIlegal Charting 9 09-27-2011 11:22 PM
Where's the horizontal pending, entry and exit lines? Antraman Charting 4 01-12-2007 02:26 AM
Horizontal Grid Lines at Price Intervals Quicktrader10 Charting 1 01-05-2007 06:04 AM
Horizontal Lines guym Suggestions And Feedback 2 12-07-2006 08:32 AM
Spacing between horizontal grid lines on Price Chart Quicktrader10 Charting 2 09-28-2006 03:32 AM


All times are GMT -6. The time now is 11:13 PM.