PDA

View Full Version : Drawing in Indicator panel


Tremblinghandtrader
04-26-2010, 11:53 PM
Hi

I am stumped as to how to get an indicator to draw not on the price panel but in its own panel. The code is just a simple narrow range indicator but I want it to print "NR4" in a separate price panel not on the main panel.

This is the code,

{
if (CurrentBar < 4) return;

range1 = Math.Abs(High[0]-Low[0]);
range2 = Math.Abs(High[1]-Low[1]);
range3 = Math.Abs(High[2]-Low[2]);
range4 = Math.Abs(High[3]-Low[3]);

if( range1 < range2 && range1 < range3 && range1 < range4)

{
DrawText("NR4"+CurrentBar,"NR4",0, Low[0] - 100, Color.BlueViolet);

}
}

How do I get it to draw in its own panel?

And also if you have a value such as in the above example of range1 , range2 etc how do you use the DrawText method to also draw the value on the chart?

J_o_s
04-27-2010, 12:17 AM
How do I get it to draw in its own panel?

I use the following code snippet, but I don't know if that is "the correct" way. Perhaps you find it useful though:


protected override void Initialize()
{
DrawOnPricePanel = false; // don't draw in the price panel
}


Regards,

Tremblinghandtrader
04-27-2010, 12:28 AM
Yep that was it. I did try that but didn't change the the Y plot values so they showed in the price panel!

Thanks.

Just need to figure out how to plot values as text now.

J_o_s
04-27-2010, 12:40 AM
Ah good that it helped. :)

Just need to figure out how to plot values as text now.
Perhaps you could use Convert.ToString() ?

For example:
DrawText("NR4"+CurrentBar, Convert.ToString(range1), 0, Low[0] - 100, Color.BlueViolet);



Regards,

Tremblinghandtrader
04-27-2010, 12:49 AM
Perhaps you could use Convert.ToString() ?


:)

Thats it. Thanks heaps.