My code is as follows:
protected override void Initialize()
{
Add(new Plot(Color.Black, "Stochastics")); // [0]
Plots[0].Pen.Width=2;
Add(new Line(Color.Red, 80, "Upper"));
Add(new Line(Color.Green, 20, "Lower"));
Add(new Line(Color.Gray, 50, "Middle"));
Lines[0].Pen.Width=2;
Lines[1].Pen.Width=2;
Lines[2].Pen.DashStyle = DashStyle.Dash;
Lines[2].Pen.Width=1;
CalculateOnBarClose = false;
AutoScale = false;
Overlay = false;
}
/// <summary>
/// Calculates the indicator value(s) at the current index.
/// </summary>
protected override void OnBarUpdate()
{
Value.Set(Stochastics(periodD,periodK,smooth).K[0]);
if (Value[0] > 80)
{
DrawRegion("Region", CurrentBar, 0, Stochastics(periodD, periodK, smooth).K, 80, Color.Empty, Color.Green, 6);
}
}
This is a test code to shade the region of Stochastics > 80 in Green color.
Any help in identifying the problem is greatly appreciated!
Richard
Comment