code:
protected override void Initialize()
{
CalculateOnBarClose = true;
adx = ADX(adxWindow);
state = new DataSeries(this);
Add(StrategyPlot(0));
Add(StrategyPlot(1));
// Set the color for the indicator plots
StrategyPlot(1).Plots[0].Pen.Color = Color.Blue;
StrategyPlot(1).Plots[0].Pen.Color = Color.Green;
// 1 = price panel, 2 = panel under the price panel, etc.
StrategyPlot(0).PanelUI = 2;
StrategyPlot(1).PanelUI = 3;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
StrategyPlot(0).Value.Set(adx[0]);
if (CurrentBar > adxWindow)
{
if (adx[0] < noTrend )
{
state[0] = -1.0; // notrend
// StrategyPlot(0).Plotcolors[0][0] = Color.Blue;
// StrategyPlot(0).Plots[0].Plotcolors[0][0] = Color.Blue;
StrategyPlot(0).Plots[0].Pen.Color = Color.Blue;
}
else if (adx[0] > trending)
{
state[0] = 1.0; // trending
StrategyPlot(0).Plots[0].Pen.Color = Color.Green;
}
else
{
state[0] = 0; // bouncing along
StrategyPlot(0).Plots[0].Pen.Color = Color.Red;
}
}
else state[0] = 0;
StrategyPlot(1).Value.Set(state[0]);
}
:code
PS: How do you add an inline code box in this forum?
Comment