Could you pls give me a hint, I am trying to convert this indicator into a strategy to give me buy signals when the line turns green and sell signals when the line turns red and NO signals when is blue, thanks
/// <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.SkyBlue), PlotStyle.Line, "Upper"));
Add(new Plot(Color.FromKnownColor(KnownColor.SkyBlue), PlotStyle.Line, "Lower"));
// Increase the default widths of the plots
Plots[0].Pen.Width = 2;
Plots[1].Pen.Width = 2;
CalculateOnBarClose = true;
Overlay = true;
// Initialize the DataSeries.
middle = new DataSeries(this);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Set the plots and the DataSeries.
Lower.Set(SMA(Low, Period)[0]);
Upper.Set(SMA(High, Period)[0]);
middle.Set((SMA(Low, Period)[0] + SMA(High, Period)[0]) / 2);
// If the average of the two plots is rising, change the plot colors.
if (Rising(middle))
{
// The indexers for PlotColors are PlotColors[plot index][bars back], so the below code would set the first plot (Upper) to black and the second plot (Lower) to green.
PlotColors[0][0] = Color.Black;
PlotColors[1][0] = Color.LimeGreen;
}
// If the average is falling, change the plot colors.
else if (Falling(middle))
{
PlotColors[0][0] = Color.Red;
PlotColors[1][0] = Color.Black;
}
// If the average remains the same, set both plots to the same color.
else
{
PlotColors[0][0] = Color.Blue;
PlotColors[1][0] = Color.Blue;
}
}

Comment