// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
[Description("Enter the description of your new custom indicator here")]
public class Expiry : Indicator
{
#region Variables
// Wizard generated variables
int [] Expiry;
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Expiry = new Int[5];
Add(new Plot(Color.FromKnownColor(KnownClor.Orange), PlotStyle.Dot, "Plot0"));
CalculateOnBarClose = false;
Overlay = false;
PriceTypeSupported =false;
Expiry[0] = 20150326;
Expiry[1] = 20150226;
Expiry[2] = 20150129;
Expiry[3] = 20141225;
Expiry[4] = 20141127;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
for( int i=0;i<4;i++)
{
if(ToDay(Time[0]) == Expiry[i]){Plot0.Set(1); break;}
else Plot0.Set(0);
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
member name error
Collapse
X
-
member name error
Hi please help me resolve error "member names cannot be same as their enclosing type"
HTML Code:Tags: None
-
Hello,
This looks to be caused by a conflict between the class name and one of your variable names.
public class Expiry : Indicator
{
#region Variables
// Wizard generated variables
int [] Expiry;
The Class needs to be unique, this will ultimately be the name of the Indicator, your Variable is the same case and same spelling of Expiry so this would be conflicting.
Please change either the Name of the indicator by changing the Class name, or change Expiry variable to something not conflicting.
I look forward to being of further assistance.
-
Not able to compile even after name change
Originally posted by NinjaTrader_Jesse View PostHello,
This looks to be caused by a conflict between the class name and one of your variable names.
public class Expiry : Indicator
{
#region Variables
// Wizard generated variables
int [] Expiry;
The Class needs to be unique, this will ultimately be the name of the Indicator, your Variable is the same case and same spelling of Expiry so this would be conflicting.
Please change either the Name of the indicator by changing the Class name, or change Expiry variable to something not conflicting.
I look forward to being of further assistance.
Comment
-
Hello,
I looked over the code and created a new indicator from your partial post,
It looks like you have a mis spelling as well as an invalid type.
After you change Expiry to any other name, you will also need to change the line:
This would need to be KnownColor, color is spelled incorrect. This can be changed to simply:Code:Add(new Plot(Color.FromKnownColor([B]KnownClor[/B].Orange), PlotStyle.Dot, "Plot0"));
Additionally where you are assigning a value to Expiry:Code:Add(new Plot(Color.Orange, PlotStyle.Dot, "Plot0"));
int should not be capitalized, in the NinjaScript editor you will see the difference for this by color, if the type is correct it will be blue, if it is not correct it would be black and you should also get an error.Code:Expiry = new Int[5];
I look forward to being of further assistance.
Comment
-
Thanks Jesse please check the following errors
Originally posted by NinjaTrader_Jesse View PostHello,
I looked over the code and created a new indicator from your partial post,
It looks like you have a mis spelling as well as an invalid type.
After you change Expiry to any other name, you will also need to change the line:
This would need to be KnownColor, color is spelled incorrect. This can be changed to simply:Code:Add(new Plot(Color.FromKnownColor([B]KnownClor[/B].Orange), PlotStyle.Dot, "Plot0"));
Additionally where you are assigning a value to Expiry:Code:Add(new Plot(Color.Orange, PlotStyle.Dot, "Plot0"));
int should not be capitalized, in the NinjaScript editor you will see the difference for this by color, if the type is correct it will be blue, if it is not correct it would be black and you should also get an error.Code:Expiry = new Int[5];
I look forward to being of further assistance.
Comment
-
Hello,
Thank you for the image.
This tells us exactly what is wrong based on the error text.
The first error listed says the name "expiry" does not exist which is correct, C# is case sensitive, you have created a variable with the name Expiry not expiry, so you would need to correct the case so they all match.
The next item is the same line, again Int would be invalid as you have Int capitalized. You need to make Int into int with a lowercase I.
The next errors: Plot0 does not exist, this would be related to the public property.
If you expand the region "Properties, if you do not have this segment of code, this would be the reason:
This defines the Plot0 you created in Initialize, this will be setting Values index 0 with the value you pass using Plot0.Set();Code:[Browsable(false)] [XmlIgnore()] public DataSeries Plot0 { get { return Values[0]; } }
The errors displayed will always tell you what is happening in the script, if in doubt you can also double click the error to take the cursor to the location of the general error.
I look forward to being of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment