searching through nt8's help guides i found this example below of how to create an indicator that will change colors depending on its current values.
this code will compile and will work as intended to, however i have tried to change the
(IsRising(Upper)) logic to if ((Upper[0]) > (Upper[1])) and other similar structures and then the code will indeed compile but nothing will be plotted and the sma will just disappear.
i want to use a structure like ((Upper[0]) > (Upper[1])) because it allows for more flexibility as the comparison periods can be changed and even optimized. ¿does anyone know how could i create such a logic for nt8?
thanks, regards.
protected override void OnStateChange()
{
if(State == State.SetDefaults)
{
Name = "Example Indicator";
// Add two plots
AddPlot(Brushes.Blue, "Upper");
AddPlot(Brushes.Orange, "Lower");
}
}
protected override void OnBarUpdate()
{
// Sets values to our two plots
Upper[0] = SMA(High, 20)[0];
Lower[0] = SMA(Low, 20)[0];
// Color the Upper plot based on plot value conditions
if (IsRising(Upper))
PlotBrushes[0][0] = Brushes.Blue;
else if (IsFalling(Upper))
PlotBrushes[0][0] = Brushes.Red;
else
PlotBrushes[0][0] = Brushes.Yellow;
// Color the Lower plot based on plot value conditions
if (Rising(Lower))
PlotBrushes[1][0] = Brushes.Blue;
else if (IsFalling(Lower))
PlotBrushes[1][0] = Brushes.Red;
else
PlotBrushes[1][0] = Brushes.Yellow;
}
public Series<double> Upper
{
get { return Values[0]; }
}
public Series<double> Lower
{
get { return Values[1]; }
}

Comment