PlotBrushes[0][0]= Range; }, it stays solid lime green. My Slopeperiod = 45 shows up in the indicator parameters, however, it does nothing when adjusted. I've been working on this all day. Frustrated as hell!
#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
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;
AddPlot(Brushes.Orange, "Slope_Color");
}
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]);
double slopePeriod1 = Math.Tan(5 * Math.PI/180);
double trueSlope = Math.Atan(slopePeriod1 * 180 / Math.PI);
if (Value[0] >= trueSlope);
{
PlotBrushes[0][0] = UpSlope;
}
if (Value[0] <= trueSlope)
{
PlotBrushes[0][0] = DownSlope;
}else {
PlotBrushes[0][0]= Range;
}
}
#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Period", Order = 1, GroupName = "Parameters")]
public int Period
{ get; set; }
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "UpSlope", Order = 2, GroupName = "Parameters")]
public Brush UpSlope
{ get; set; }
[Browsable(false)]
public string UpSlopeSerializable
{
get { return Serialize.BrushToString(UpSlope); }
set { UpSlope = Serialize.StringToBrush(value); }
}
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "DownSlope", Order = 3, GroupName = "Parameters")]
public Brush DownSlope
{ get; set; }
[Browsable(false)]
public string DownSlopeSerializable
{
get { return Serialize.BrushToString(DownSlope); }
set { DownSlope = Serialize.StringToBrush(value); }
}
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "Range", Order = 4, GroupName = "Parameters")]
public Brush Range
{ get; set; }
[Browsable(false)]
public string RangeSerializable
{
get { return Serialize.BrushToString(Range); }
set { Range = Serialize.StringToBrush(value); }
}
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "SlopePeriod", Order = 5, GroupName = "Parameters")]
public int SlopePeriod
{ get; set; }
#endregion
}
}
#region NinjaScript generated code. Neither change nor remove.
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private MyTest[] cacheMyTest;
public MyTest MyTest(int period, Brush upSlope, Brush downSlope, Brush range, int slopePeriod)
{
return MyTest(Input, period, upSlope, downSlope, range, slopePeriod);
}
public MyTest MyTest(ISeries<double> input, int period, Brush upSlope, Brush downSlope, Brush range, int slopePeriod)
{
if (cacheMyTest != null)
for (int idx = 0; idx < cacheMyTest.Length; idx++)
if (cacheMyTest[idx] != null && cacheMyTest[idx].Period == period && cacheMyTest[idx].UpSlope == upSlope && cacheMyTest[idx].DownSlope == downSlope && cacheMyTest[idx].Range == range && cacheMyTest[idx].SlopePeriod == slopePeriod && cacheMyTest[idx].EqualsInput(input))
return cacheMyTest[idx];
return CacheIndicator<MyTest>(new MyTest(){ Period = period, UpSlope = upSlope, DownSlope = downSlope, Range = range, SlopePeriod = slopePeriod }, input, ref cacheMyTest);
}
}
}
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.MyTest MyTest(int period, Brush upSlope, Brush downSlope, Brush range, int slopePeriod)
{
return indicator.MyTest(Input, period, upSlope, downSlope, range, slopePeriod);
}
public Indicators.MyTest MyTest(ISeries<double> input , int period, Brush upSlope, Brush downSlope, Brush range, int slopePeriod)
{
return indicator.MyTest(input, period, upSlope, downSlope, range, slopePeriod);
}
}
}
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.MyTest MyTest(int period, Brush upSlope, Brush downSlope, Brush range, int slopePeriod)
{
return indicator.MyTest(Input, period, upSlope, downSlope, range, slopePeriod);
}
public Indicators.MyTest MyTest(ISeries<double> input , int period, Brush upSlope, Brush downSlope, Brush range, int slopePeriod)
{
return indicator.MyTest(input, period, upSlope, downSlope, range, slopePeriod);
}
}
}
#endregion
Comment