I created a simple indicator that can display the Parabolic SAR in normal mode or as a horizontal line.
I can compile it without any problems, and it works on the chart as well. I can export it as a zip file, but when I try to import the zip file on another computer, I get an error window.
I have created several indicators before, and this is the first time I have encountered this error. Can you help me solve this problem?
I paste the entire source code of the indicator.
namespace EA_Namespace
{
public enum EA_ParabolicMode : ushort{
Egyenes_Parabolic = 0,
Mozgo_Parabolic = 1
}
}
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class ParabolicEA : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "ParabolicEA";
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 = false;
CandleCount = 1000;
ParabolicMode = EA_Namespace.EA_ParabolicMode.Egyenes_Parabolic;
ParabolicAcceleration = 0.02;
ParabolicAccelerationMax = 0.2;
ParabolicAccelerationStep = 0.02;
//ParabolicColor = Brushes.Yellow;
AddPlot(new Stroke(Brushes.Azure, DashStyleHelper.Solid, 1, 50), PlotStyle.Dot, "Parabolic_Long");
AddPlot(new Stroke(Brushes.Azure, DashStyleHelper.Solid, 1, 50), PlotStyle.Dot, "Parabolic_Short");
}else if (State == State.Configure){
}
}
protected override void OnBarUpdate()
{
int candle_index = Bars.Count - CurrentBar - 1;
if(candle_index < CandleCount && candle_index < Bars.Count - 3){
//PlotBrushes[0][0] = ParabolicColor;
//PlotBrushes[1][0] = ParabolicColor;
double value_0 = ParabolicSAR(ParabolicAcceleration, ParabolicAccelerationMax, ParabolicAccelerationStep)[0];
double value_1 = ParabolicSAR(ParabolicAcceleration, ParabolicAccelerationMax, ParabolicAccelerationStep)[1];
double open_0 = Open[0];
double open_1 = Open[1];
double close_0 = Close[0];
double close_1 = Close[1];
int dir_0 = 0;
if(value_0 < Math.Min(open_0, close_0)){
dir_0 = 1;
}else if(value_0 > Math.Max(open_0, close_0)){
dir_0 = -1;
}
int dir_1 = 0;
if(value_1 < Math.Min(open_1, close_1)){
dir_1 = 1;
}else if(value_1 > Math.Max(open_1, close_1)){
dir_1 = -1;
}
if(dir_0 != dir_1){
if(dir_0 == 1){
Parabolic_Long[0] = value_0;
Parabolic_Short[0] = Double.NaN;
}else{
Parabolic_Short[0] = value_0;
Parabolic_Long[0] = Double.NaN;
}
}else{
if(ParabolicMode == EA_Namespace.EA_ParabolicMode.Egyenes_Parabolic){
if(dir_0 == 1){
Parabolic_Long[0] = Parabolic_Long[1];
Parabolic_Short[0] = Double.NaN;
}else if(dir_0 == -1){
Parabolic_Long[0] = Double.NaN;
Parabolic_Short[0] = Parabolic_Short[1];
}
}else{
if(dir_0 == 1){
Parabolic_Long[0] = value_0;
Parabolic_Short[0] = Double.NaN;
}else{
Parabolic_Short[0] = value_0;
Parabolic_Long[0] = Double.NaN;
}
}
}
}
}
[NinjaScriptProperty]
[Display(Name="Gyertya Db", Description="Ennyi Gyertyába Rajzoljuk", Order=1, GroupName="Parameters")]
public int CandleCount
{ get; set; }
[NinjaScriptProperty]
[Display(Name="Parabolic Módszer", Description="Így rajzoljuk a parabolicot", Order=2, GroupName="Parameters")]
public EA_Namespace.EA_ParabolicMode ParabolicMode
{ get; set; }
[NinjaScriptProperty]
[Display(Name="Parabolic Acceleration", Description="Parabolic Acceleration", Order=3, GroupName="Parameters")]
public double ParabolicAcceleration
{ get; set; }
[NinjaScriptProperty]
[Display(Name="Parabolic Acceleration Max", Description="Parabolic Acceleration Max", Order=4, GroupName="Parameters")]
public double ParabolicAccelerationMax
{ get; set; }
[NinjaScriptProperty]
[Display(Name="Parabolic Acceleration Step", Description="Parabolic Acceleration Step", Order=5, GroupName="Parameters")]
public double ParabolicAccelerationStep
{ get; set; }
/*
[NinjaScriptProperty]
[Display(Name="Parabolic Szin", Description="Parabolic Szin", Order=6, GroupName="Parameters")]
public Brush ParabolicColor
{ get; set; }
*/
[Browsable(false)]
[XmlIgnore]
public Series<double> Parabolic_Long
{
get { return Values[0]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> Parabolic_Short
{
get { return Values[1]; }
}
}
}
The error message:
Finally I attach the zip the Ninjatrader generated.
Laszlo

Comment