![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
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.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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. |
|
|
|
|
|
#4 |
|
Member
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
|
|
|
|
|
|
#6 |
|
Member
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
|
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jun 2007
Posts: 218
Thanks: 0
Thanked 1 time in 1 post
|
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() |
|
|
|
|
|
#9 |
|
Member
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
|
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.
???? |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Jun 2007
Posts: 218
Thanks: 0
Thanked 1 time in 1 post
|
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]; |
|
|
|
|
|
#11 |
|
Member
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#12 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
That's great!
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |