PDA

View Full Version : Plot High/Low of bar on right scale


fs
06-24-2009, 05:29 PM
Hi

I like to plot the high and low of each bar on the right scale like the current price. I have written simple code to do that as below. It works fine, but the only way I am able to plot the high/low values on the right scale is by plotting a dot on the high and low of each bar. I'd prefer to just see the values on the right scale without having to plot dots on the chart as I find this distracting. Is there a way to do that? If I make the dots the same as the background color, it mask a little bit off the high and low of the bar since it is actually overlapping.

-----------------------------------------------------------------
namespace NinjaTrader.Indicator
{
/// <summary>
/// Plot the High and Low of each bar on the right scale
/// </summary>
[Description("Plot the High and Low of each bar on the right scale")]
public class FSIPlotHL : Indicator
{
#region Variables
// Wizard generated variables
private Color HighColor = Color.LimeGreen; // Default setting for HighColor
private Color LowColor = Color.Red; // Default setting for LowColor
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Dot, "HighPlot"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "LowPlot"));
CalculateOnBarClose = false;
Overlay = false;
PriceTypeSupported = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
HighPlot.Set(High[0]);
LowPlot.Set(Low[0]);
}

#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries HighPlot
{
get { return Values[0]; }
}

[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries LowPlot
{
get { return Values[1]; }
}

[XmlIgnore()]
[Description("High Color")]
[Category("Parameters")]
public Color highColor
{
get { return HighColor; }
set { HighColor = value; }
}

// Serialize our Color object
[Browsable(false)]
public string noDemandColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString( HighColor); }
set { HighColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
}

[XmlIgnore()]
[Description("Low Color")]
[Category("Parameters")]
public Color lowColor
{
get { return LowColor; }
set { LowColor = value; }
}

// Serialize our Color object
[Browsable(false)]
public string LowColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString( LowColor); }
set { LowColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
}

#endregion
}
}

--------------------------------------------------------------------------------

NinjaTrader_Bertrand
06-25-2009, 06:08 AM
fs, have you tried setting the dots to 'transparent'? This would still display the value on the right side scale...

fs
06-25-2009, 11:29 AM
Hi

Thank you for your suggestion. That almost worked. The dots don't show up when setting to transparent, but unfortunately the values on the right scale are also transparent and show up as "empty" price boxes.

NinjaTrader_Bertrand
06-25-2009, 11:37 AM
Yes, that is correct - maybe you can can access the needed values also in the DataBox, or you plot them right to the currentbar on the chart with DrawText.

eDanny
06-25-2009, 11:40 AM
You can always make the dot size zero, and set to the color you want in the mean time. Or even change to Hash style.

fs
06-25-2009, 11:59 AM
Thanks again for the replies. What I have done now is setting the size to zero. I will look up how drawtext work to display that at the bottom of the screen like the time counter indicator do. Still feeling my way around in NT script.