View Full Version : Draw Horizontal Lines
08-01-2007, 12:44 PM
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.
08-01-2007, 01:09 PM
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.
08-01-2007, 01:19 PM
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.
08-01-2007, 02:22 PM
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.
08-01-2007, 02:30 PM
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.
08-01-2007, 03:15 PM
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.
if (CurrentBar < 2)
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?
08-01-2007, 03:52 PM
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.
08-01-2007, 03:57 PM
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()
08-02-2007, 06:21 AM
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.
08-02-2007, 06:36 AM
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 :
08-02-2007, 12:12 PM
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.
08-02-2007, 12:23 PM