My first indicator, in which I attempted to plot a triangle on a bar where the low of current bar is > than the high of the previous bar. Unfortunately I am getting a series of triangles plotted along the bottom of the chart at 0.00 price level. If anyone could help, I would appreciate it.
Here is the code:
public class PriceAction : Indicator
{
#region Variables
// Wizard generated variables
// 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.RoyalBlue), PlotStyle.TriangleUp, "Plot0"));
Overlay = true;
}
/// <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.
Plot0.Set(Low[0] > High[-1] ? 1 : 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 Plot0
{
get { return Values[0]; }
}
#endregion
}
}
Comment