PDA

View Full Version : Markers in Indicator Panels


Richard Von
08-24-2007, 12:59 PM
I want to draw markers (Diamonds, arrows, squares) in an indicator panel(like MACD) upon certain conditions. I can successfully find the conditions and make a sound play, but cannot make any marker appear in the MACD panel. I have been able to use similar conditions and make markers appear in the price panel.

I am putting the right panel number when I set up the indicator but no joy.

For example, I've tried:

string myTag = "myTag" + TagNbr.ToString();
DrawDiamond(myTag, 0, MACD(Fast,Slow,Smooth)[0] + .01, Color.Red);
TagNbr = TagNbr + 1;

Nothing appears. Can this be done?

NinjaTrader_Ray
08-24-2007, 01:04 PM
Yes, this can be done. You have to set the following property in your custom indicator's Initialize() method:

DrawOnPricePanel = false;

Here is additional information - http://www.ninjatrader-support.com/HelpGuideV6/DrawPriceOnPanel.html

Richard Von
08-24-2007, 01:08 PM
Thank you. By the way, note that the description of this in the help dialogue does not tell you WHERE to put this as you have below.

NinjaTrader_Ray
08-24-2007, 01:18 PM
Thanks, I will ammend the documentation to make it more clear.

gregiii
08-26-2007, 04:09 PM
Yes, this can be done. You have to set the following property in your custom indicator's Initialize() method:

DrawOnPricePanel = false;

Here is additional information - http://www.ninjatrader-support.com/HelpGuideV6/DrawPriceOnPanel.html

Overlay =false;
DrawOnPricePanel = false or true

DrawLine(CurrentBar.ToString(),0,0,0,800,Color.Red ,DashStyle.Solid,1);

always draw on price panel.

Or did I do something wrong?

NinjaTrader_Ray
08-26-2007, 06:01 PM
Likely did something wrong.

I added this to one of my custom indicators and it worked as expected. Keep in mind, my indicator did have a value of 0.4 on it so my line displayed.


if (CurrentBar > 2)
DrawLine("Tag1", 2, 0.4, 0, 0.4, Color.Red, DashStyle.Solid, 2);

gregiii
08-26-2007, 07:46 PM
Likely did something wrong.

I added this to one of my custom indicators and it worked as expected. Keep in mind, my indicator did have a value of 0.4 on it so my line displayed.


if (CurrentBar > 2)
DrawLine("Tag1", 2, 0.4, 0, 0.4, Color.Red, DashStyle.Solid, 2);



if you toggle DrawOnPricePanel=false/ture, does your line move to price panel, move to indicator panel accordingly?

I am just trying to draw a vertical line on the bottom indicator panel. The height of the line varies with indicator's value. It keeps drawing on price panel. I am doing this to work around the bug that I need to Add() mutiple plots to change color. See my other posts. http://www.ninjatrader-support.com/vb/showthread.php?t=2936

With everything else stays the same. I tested DrawText(), DrawRectangle(), these all work just as expected, but DrawLine() does not.

Here is the bare minimum test script. compare the image with the *.cs file. The vertical line shoud appear at the bottom.

NinjaTrader_Ray
08-27-2007, 07:02 AM
Your script works as expected. If you make changes to your script, to see these changes in the chart on an already active indicator, you must reload it by pressing F5 in your chart.

gregiii
08-27-2007, 10:18 AM
This is absolutely strange!

Not only I reload with F5, I also shut down NT and rebooted machine today. It consistently produces the chart I posted. Vertical line never goes to the bottom indicator chart. And if you commented out DrawLine(..) statement, DrawText() works as expected. But with DrawLine(..) active, DrawText() does not work either, ie, no character "a" is seen anywhere in the chart.

Can you post an image of chart just with my script loaded, with DrawOnPricePanel = false and DrawOnPricePanel = true.

Thanks

NinjaTrader_Ray
08-27-2007, 11:30 AM
See images.

Also, managing a lot of draw objects is not optimal, especially if you have many bars on your chart. I would do one of two things -

- Use a plot with style bar or;
- Limit the number of lines drawn to no more than a few hundreded

NinjaTrader_Ray
08-27-2007, 11:30 AM
The other image.

gregiii
08-27-2007, 12:08 PM
Thanks Ray.

I don't know what to say...

I have not been able to produce a chart with vertical line at the bottom at all. Not even a single line. My original code has if () condition so only a few vertical line would be drawn if DrawLine() works for me.

I know to use bar style to draw indicator. But I only want to draw a few line on the indicator when certain conditions meet.

So with my script, you can generate a correct chart, but I can't! Any suggestions?

NinjaTrader_Ray
08-27-2007, 12:26 PM
I would then speculate that the indicator you are working with on the chart is not the one you are modifying in the Editor.

Try creating a brand new indicator with a different name to confirm.

gregiii
08-27-2007, 12:45 PM
I am taling about just using the ttt.cs script I posted. Nothing else is on the chart. The same way you did. But I can't produce the same result as you did. Ture or False, these vertical line always show up at the price panel. Never goes to the bottom panel.

And Yes, I recompiled, reloaded, restarted NT etc. Result is the same.

And yes it is the same indicator as in editor, because I can change the color of the line, just not the location.


That's what's puzzuling

NinjaTrader_Ray
08-27-2007, 12:53 PM
I don't doubt you.

To debug, we always need to start at the most basic level. The function for sure works as expected. Therefore, there *MUST* be something on your PC different than mine.

Therefore, create a new indicator with a new name and test this. Assuming this works, then we know there is something with your indicator.

gregiii
08-27-2007, 01:27 PM
Here is what I just did.

Closed all charts, MA, then Shut down NT.

Restart NT, now not a single chart open.

Created a new indicator called "qqq.cs", just like the ttt.cs.

Open a new chart, load qqq.

Same result. :mad:

NinjaTrader_Ray
08-27-2007, 01:52 PM
Try this.

Import this file. Open a new chart. Apply PanelTrue and PanelFalse indicators. Post an image of what you get.

Thanks

gregiii
08-27-2007, 02:20 PM
Here it is.

gregiii
08-27-2007, 02:29 PM
here is more clearer, as I changed PanelFalse line to Black, Dot.

gregiii
08-27-2007, 02:42 PM
Also, with these two indicator loaded, NT is running very slow. It is trying to do something.. Unload them, everything back to normal.

NinjaTrader_Ray
08-27-2007, 03:29 PM
I am stumped like you are. I will look into the performance issue, I see that here as well.

My last suggestions.

- Make sure the panel properties when adding the indicators on the chart are 2 and 3
- Try a complete uninstaller (deleting My Documents\NinjaTrader 6 folder) and re-install. You will lose user data in this process.

NinjaTrader_Ray
08-28-2007, 10:41 AM
Thanks for the suggestion.

gregiii
08-28-2007, 10:46 AM
Ray,

1) I reinstalled NT on my other machine. And yes it works after reinstall. But all it says is that this function works under some conditions. I am still not confident to use it in my indicator yet becuase a few weeks from now it may quit working. I mean NT is working just fine otherwise, but a few functions (DrawLine, DrawRay) does not, then you have to reinstall NT to make it work. To me, it says these functions may have some issues. Hope you guy can look into it.

On a related note:

2) I am doing this (drawing line at indicator panel) is to create an indicator with different color without doing multiple Add(..), becuase doing so will mess up the DataBox and more resource consuming. An indicator with 4 color will essentially require 4 indicators.

Can you look into these possibilites that will let us create indicators with changing colors:

a) Allow plot's pen being changed after initialize() function, e.g.,

if value<0
Plot[0].Pen = new Pen(Color.Red,2);
else if value=0
Plot[0].Pen = new Pen(Color.Yellow,2);
else
Plot[0].Pen = new Pen(Color.Green,2);

That way indicator's color changes with its value. Right now if you do this way the indicator still stays the same color depends on its initial value.

b) Find a way to hide additional indicator from Databox, e.g,

Plot[1].ShowDataBox = true/false;

So we still do mutiple Add(..) for each color, but we hide them from Databox.

or c) whatever you may think of..

Thanks for considering.