Getting error codes:
The name 'trueSlope' does not exist in the current context CS0103 Line 61
'System.math' does not contain a definition for "Pi" CS0117 Line 61
No overload for method 'Slope' takes 1 arguments CS1501 Line 64
Cannot implicitly convert type "System.Windows.Media.Brush" to NinjaTrader.NinjaScript.BrushSeries CS0029 Line 66
Cannot implicitly convert type "System.Windows.Media.Brush" to NinjaTrader.NinjaScript.BrushSeries CS0029 Line 68
public class MyTest : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MyTest";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
Period = 14;
UpSlope = Brushes.LimeGreen;
DownSlope = Brushes.Red;
Range = Brushes.Blue;
SlopePeriod = 45;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
Value[0] = (CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);
trueSlope = Math.Atan(SlopePeriod * 180/Math.Pi);
if (Slope(Value) >= trueSlope)
{
PlotBrushes[0] = UpSlope;
} else {
PlotBrushes[0] = Range;
}
if (Slope(Value) <= trueSlope)
{
PlotBrushes[0] = DownSlope;
} else {
PlotBrushes[0] = Range;
}
}
Comment