I have to wrap this line of code: if (ChartControl != null)
around OnBarUpdate() section of code to Enable checkbox to stay on and enabled for Strategy Builder. All the code except the vertical lines is a template that was prebuilt. I added an indicator for the trend strength which shows vertical lines and the Colored Label on the upper right side of the chart. I can't get the vertical lines to be read by StrategyBuilder using a value of TrendBreak that I named. How can I get TrendBreak to work to pass the value to Strategy Builder as I have used this way of passing values to Strategy Builder previously, but those aren't using a template, where as I'm adding an indicator that only strength and weakness vertical lines and a Trend label like this is?
public class StackedEMAs : Indicator
{
private Series<double> trendBreak;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
AddPlot(new Stroke(Brushes.Transparent, 2), PlotStyle.Bar, "TrendBreak");
}
else if (State == State.DataLoaded)
{
trendBreak = new Series<double>(this);
}
}
// OnBarUpdate code
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
if (ChartControl != null)
{
EMA8 = EMA(8)[0];
EMA5 = EMA(5)[0];
SNS = EMA5 < EMA8
if (SNS) // Negative
{
trendBreak[0] = -1;
}
// Properties
[Browsable(false)]
[XmlIgnore]
public Series<double> TrendBreak
{
get { return trendBreak; }
}
Comment